connect() returns -1

This is a discussion on connect() returns -1 within the Networking/Device Communication forums, part of the General Programming Boards category; Hmm...I get a errormessage saying connect() returns -1... (Yes, thorugh error-checking) What do this mean? -1 arent on the MSDN-list ...

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

    connect() returns -1

    Hmm...I get a errormessage saying connect() returns -1...
    (Yes, thorugh error-checking)

    What do this mean?
    -1 arent on the MSDN-list of possible errors

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    MSDN says connect() returns SOCKET_ERROR if the function fails. SOCKET_ERROR is probably defined as -1. Call WSAGetLastError() to get the actual error code to get more information.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    You will find that the errors in all caps, are sometimes a defined error number like

    Code:
    #define ERROR -2
    #define OTHERERROR -1
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  4. #4
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Yeah SOCKET_ERROR is defined as -1. So basically yeah you aren't connecting, use WSAGetLastError() to see whats up . Assuming you are using winsock of course.... oh I am repeating what bithub said... oh well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 09:32 AM
  2. connect timeout
    By X PaYnE X in forum Networking/Device Communication
    Replies: 8
    Last Post: 05-14-2005, 10:30 PM
  3. Client timed-out once on connect(), can never connect() again
    By registering in forum Networking/Device Communication
    Replies: 6
    Last Post: 10-28-2003, 03:46 PM
  4. connect() returns "Network unreachable", but it isn't??
    By registering in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-22-2003, 03:09 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21