Jump to content
  • Advertisement
Sign in to follow this  
eran65

Socket.Close()

This topic is 2703 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

hello, as i understand it in C# u pass a copy of the reference by default,
no for my Example

iv'e got 2 Forms witch in the first a Socket connects and then is being passed in the constractor to the other form

now as i understand it they both have a reference to the same place in memory ,
now in the second form i call Socket.Close()
when the second form closes , the first form is up

and the socket witch is used there was of course set to close, i want to detect that status of the socket
something like if(Socket.Closed)

this is because in some situations i Call Socket.Disconnect(true) , and when errors occur i call Socket.Close()

my questions are :
1) how to detect if a socket is closed and not disconnected on The side it was closed on,
(please try to understand that i could well of said a oledb connection,the socket is not
the issue as much as detecting if a closeable object was closed)
2) can the reference of the Socket object be set to null , then the other Socket would also reference null and that i could detect

Share this post


Link to post
Share on other sites
Advertisement

1) how to detect if a socket is closed and not disconnected on The side it was closed on,
(please try to understand that i could well of said a oledb connection,the socket is not
the issue as much as detecting if a closeable object was closed)
2) can the reference of the Socket object be set to null , then the other Socket would also reference null and that i could detect



1) You can poll the Connected property of the socket to test whether it is connected. However, I'd rather wrap the socket in some class that "owns" the socket and issues appropriate events based on what's going on with the socket. Each separate form could then listen to those events.
2) When you assign a reference member to null, just that member is set to null, not the object in question. Thus, this won't affect other references.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!