The following code example demonstrates how to close a Socket. For connection-oriented protocols, it is recommended that you call Shutdown before calling Close. If you need to call Close without first calling Shutdown , you can ensure that data queued for outgoing transmission will be sent by setting the DontLinger option to false and specifying a non-zero time-out interval.
To set the DontLinger socket option to false , create a LingerOption , set the enabled property to true , and set the LingerTime property to the desired time-out period. Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. Privacy policy. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info.
In this, ping method is excellent. I suggested about ping method in my solution 2. If error occurs even though implementing ping method, send comment again to discuss with me. I am very interested and skilled in internet communication programming such as linphone i.
I would suggest that you try to use transaction based connections instead of sessions based, that means that the client 1. If this is a feasible way or not for you depends on your control of the software and how the communication behaviour of the clients looks like. Posted 2-Dec pm George Jonsson. It's a good idea. I'll add this as an option to my clients.
But I think this is useful is smaller networks because the time cost of creating a thread in server for each transaction is too much. But I think this is useful in smaller networks because the time cost of creating a thread in server for each transaction is too much. Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account.
This email is in use. Do you need your password? Submit your solution! When answering a question please: Read the question carefully. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid. Related Questions. You may be unaware that closing the input or output stream of a socket closes the other stream and the socket as well. For 'software caused connection abort' see the duplicate link. I had the same problem and the solution was not use socket. You can read more about it in this post. You are facing a connection breakdown. Does this happen in 3G, WiFi or "plain" connection on a computer?
Anyway, you must assume that the connection may be lost from time to time, when writing your app. For example, with mobiles, this happens frequently in the tube, in basements, etc. With PC apps, this is less frequent but occurs sometimes. The isConnected and isClosed methods are about the state of the socket, not the state of the connection.
From your code, remove: OutputStream. Thanks for the info, you saves my time : — javiercruzweb. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 6.
0コメント