CAsyncSocket::Connect() error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: CAsyncSocket::Connect() error

  1. #1
    Join Date
    Feb 2001
    Posts
    12

    CAsyncSocket::Connect() error

    Hello everybody,

    I 'm using a CAsyncSocket class in a VisualC++ program.

    When I'm working on WIN98 everything works fine. But, on Windows 2000 a WSAEINVAL (10022) error occures.

    mySocket.Create();
    BOOL b = mySocket.Connect(''"ftp.microsoft.com", 21); //CLIENT see doc
    if(b == FALSE)
    int err = CAsyncSocket::GetLastError();


    Can you give me some idea?

    Tanks,
    Gelu

  2. #2
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147
    The error is telling you that there is an invalid parameter in the call.

    The port number is difficult to mess up, but the host address could be badly formatted (as shown in your example).

    If you want, you can also specify the ip address in the host string. This way the application doesn't need to resolve the address;

    BOOL b = mySocket.Connect("207.46.133.140", 21);

    I would check your original string though. It looks incorrect in the example you show (there's something unusual about the beginning of the string).

    Hope this helps,

    - Nigel

  3. #3
    Join Date
    Feb 2001
    Posts
    12
    Hello Nigel,
    There is a cut & paste error in my example.

    I analyzed better my code:

    The mySocket.Connect() function always returns FALSE and the last error code vary between 10022 and 10035.
    I tried it with verified IP addresses and ports.

    But, sometime, the socket is connected properly and I can work with.

    Thanks,
    Gelu

  4. #4
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    A return value of 10035 is not an error. It is to be expected.
    It is WSAEWOULDBLOCK which means that the requested
    operation would block and this is a non-blocking socket. The operation will be completed latter and your program will be
    notified with the OnConnect callback.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  5. #5
    Join Date
    Feb 2001
    Posts
    12
    this info seems to be very helpfull for me. I will try it soon .
    Thanks

  6. #6
    Join Date
    Feb 2001
    Posts
    12
    Actually, on Windows 2000, it returns always FALSE with error = 10022

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center