Jump to content
  • Advertisement
Sign in to follow this  
phb5000

[.net] TcpClient Exception

This topic is 4389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple application with a network stream using the TcpClient class. My operations are setup and run using the Async methods (Being... / End...) Everything works fine until I want to close the connection, or re-connect. When I try to call the BeginConnect the second time (after closing the existing stream) I get a SocketException. Its driving me crazy!!! I dont know why it is thrown Here is the exact error: SocketException was unhandled ------------------------------- The attempted operation is not supported for the type of object referenced. ErrorCode: 10045 Please help me with this! :)

Share this post


Link to post
Share on other sites
Advertisement
You aren't supposed to reuse TcpClient objects. Close() calls Dispose().

Share this post


Link to post
Share on other sites
I do:

Close() etc...
tcp = null;
tcp = new TcpClient(...);

I make a completely new isntance of the TcpClient.
Should i not do that?

Share this post


Link to post
Share on other sites
I'm guessing the problem is related to the fact that I'm using the Async calls. I never had this problem when I ran the normal Read / Write methods.

Any ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!