CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Posts
    4

    [RESOLVED] TCPClient sockets

    Hello,

    I am not sure if theis is the correct place to ask this question, so if I am wrong then please just inform me where it should be placed.

    I am opening a socket connection to a server, send a message, receiving a reply and close the socket all this goes very well so far. But when I close the socket the last message I sent gets sent again, which confuses me. Why would a TCPClient.Close() send the data again. Could someone explain to me why this might happen and how I should close the socket so that it does not send the message again.

    Thanks

    Mike

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: TCPClient sockets

    Normally the message would not get sent again. However, it is very difficult for us to tell what might be happening without seeing your code. Could you post some of the code where you think the problem might be.

    don't forget to use Code tags

  3. #3
    Join Date
    May 2007
    Posts
    1,546

    Re: TCPClient sockets

    That's not how TCP sockets work. Every byte is sent at the most once. If messages are arriving twice it's because you're sending them twice. Are you 100% sure you're not sending the same messages twice?
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  4. #4
    Join Date
    Aug 2011
    Posts
    4

    Re: [RESOLVED] TCPClient sockets

    After testing this problem many times I determined that the socket cannot be sending the message when I close the socket. Still I was seeing the message posted on the server again after the close. So I wrote up a second app in c++ to see what was going on. Well sure enough the same thing was happening. So I have determined that it is the server that is causing this apparent send after the close. Unfortunately I did not create this server module so I cannot check it to see why it is doing it, so I will live with this wierd action.

    Thank you all for responding to my question, I appreciate it very much.

    Mike

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