c# - Socket.Shutdown and threads -


i'm pretty new socket programming. our application uses sockets communicate device our company manufactures. have problem socket taking long time close.

here's code run when time close socket:

if (client != null) {     try {         if (client.connected) {             client.disconnect(false);             client.shutdown(socketshutdown.both);         }          client.close();     } catch (socketexception) {     }      client = null; } 

i've read documentation socket.shutdown method , the responses question , i'm confused. data pending transfer remote system system, or vice versa, transferred or abandoned? if data pending transfer abandoned, delaying socket's closure?

call shutdown before close can make sure data queued received.

do not call disconnect. why necessary? no reason. wrong before shutting down. think whether makes sense or not.

call dispose or close after shutdown release os resources. connection reliably closed now.

do not swallow socketexception. why doing this? you'll never find out data sent not received.

we have problem socket taking long time close.

how know? symptoms of this?


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -