Thread: bind( ) and errno

  1. #1
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718

    bind( ) and errno

    For some reason whenever bind (or any other Winsock function) returns an error, errno is still set to 0. Any ideas as to what might be causing this?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Use WSAGetLastError() to get the last error for winsocks.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    No idea. I usually get my error codes, but sometimes they disappear. Usually it's because I've screwed up somewhere else though A more specific explanation from someone would be nice though.

    **EDIT** Well, yes use WSAGetLastError if you're using Winsock, but those sometimes disappear on me too.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well for winsocks WSAGetLastError() only work on commands like accept, bind, listen, etc. If using WSAAsyncSelect the error message is stored in the HIWORD of lparam.

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Well for winsocks WSAGetLastError() only work on commands like accept, bind, listen, etc. If using WSAAsyncSelect the error message is stored in the HIWORD of lparam.
    Not true... recv() at least should generate errors retreivable by WSAGetLastError(). When a remote socket drops, recv() will return SOCKET_ERROR and set the error to WSAECONNRESET. I'm pretty sure the other functions have similar function; I highly doubt MS would make a function like WSAGetLastError() only for the least-used socket functions (i.e. connecting/binding/etc.).
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    did you not see the ETC?!?!?!

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Sorry, brain isn't working today.
    [whine]
    Went for road test for a drivers license and got a real jerk who was exceedingly rude and failed me on the basis of being too hesitant (i.e. not aggressive enough) and then wouldn't let my sister talk to the manager on the phone when she called to lodge a complaint, and mouthed off at her too. I think he was an abused child or something.
    [/whine]

    Since those 3 you put pretty much included everything except for recv() and send() and you said "only works for" I figured you meant to exclude those two My bad.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2008, 11:57 AM