CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2014
    Posts
    5

    MFC CSocket Timeout

    Hallo
    I have a problem with MFC CSocket.
    Trying to Connect a Client works with “localhost” and fails with all other systems.
    The same address and port is reachable with telnet in any case.
    I have checked all firewall settings, I turned off firewall, nothing helps.
    Trying to connect with a MFC CSocket, fails with time-out. After that the first try to connect with telnet also fails. The second and the subsequent calls are working normally.
    The System is: Win7 Enterprise 64bit with Service Pack 1
    Does anyone have an idea?

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: MFC CSocket Timeout

    Try to connect to 127.0.0.1 and see if you get the same thing.
    It is also possible that you are getting something like "..1" for loopback,
    sometimes IPV6 results leak into your IPV4 API calls.

    I suggest t step through your code with a debugger and watch all the return
    values and reference variable values after each call. See if you are getting
    what you expect. If the values are confusing, try to figure out why or post
    them back to this site.
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    May 2014
    Posts
    5

    Re: MFC CSocket Timeout

    It does't matter if i connect to "localhost", "127.0.0.1" or my own IP-Address 192.168.0.6, it works.
    Only if i try to connect to p.e. 192.168.0.5 it fails, but only when i try with my App using CSocket, with Telnet it works.
    The Function Connect fails with GetLastError() == Time-Out.

  4. #4
    Join Date
    May 2014
    Posts
    5

    Re: MFC CSocket Timeout

    I use my own CSocket Class since Years in a lot of difference Apps and it works on every System i ever installed my Apps.
    But since a couple of weeks i have this problem only on my own System.

  5. #5
    Join Date
    Mar 2001
    Posts
    2,529

    Re: MFC CSocket Timeout

    Hmm is it a blocking or NON-BLOCKING socket? What about WSAEGetLastError()? GetLastError() doesn't really give you the full picture.
    ahoodin
    To keep the plot moving, that's why.

  6. #6
    Join Date
    May 2014
    Posts
    5

    Re: MFC CSocket Timeout

    It's a blocking Socket and WSAGetLastError() return the same value: 10060

  7. #7
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC CSocket Timeout

    Is there a very good reason to use a blocking Socket?
    Did you try the CAsyncSocket instead?
    Victor Nijegorodov

  8. #8
    Join Date
    May 2014
    Posts
    5

    Re: MFC CSocket Timeout

    I try CAsyncSocket, yes, same result. But now the problem is solved. With the latest Win7 Update the problem disappeared.
    I don't know what it was, but it works now.
    Thanks for your help.

  9. #9
    Join Date
    Mar 2001
    Posts
    2,529

    Re: MFC CSocket Timeout

    Hmm bet the issue was a firewall.
    ahoodin
    To keep the plot moving, that's why.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured