Thread: is a socket writable

  1. #1
    Politics&Cpp geek Da-Nuka's Avatar
    Join Date
    Oct 2004
    Posts
    104

    is a socket writable

    How can i find out if a socket if writable?
    I am programming for windows.
    I would like the easiest solution(Dont need to be portable, i love windows )

    If you plan to reffer to the select() function, i have looked it up on MSDN , and
    1. I did not understand it
    2. It looks like a overkill for this little task

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    You're implying a an active socket (connected) correct? In that case, select() is a good solution.

    Kuphryn

  3. #3
    Politics&Cpp geek Da-Nuka's Avatar
    Join Date
    Oct 2004
    Posts
    104
    How about something like:

    Code:
    if((socket != NULL) && (socket != SOCKET_ERROR) && (socket != INVALID_SOCKET))

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    That wont work. The only way to tell (that I know of) whether you can write to a socket is to call select(). You can find an example at http://www.ecst.csuchico.edu/~beej/g...et_old/#select

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Non-blocking socket connection problem
    By cbalu in forum Linux Programming
    Replies: 25
    Last Post: 06-03-2009, 02:15 AM
  2. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  3. Socket Help - Multiple Clients
    By project95talon in forum C Programming
    Replies: 5
    Last Post: 11-17-2005, 02:51 AM
  4. when to close a socket
    By Wisefool in forum Networking/Device Communication
    Replies: 5
    Last Post: 11-02-2003, 10:33 AM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM