So I've got a socket that is connected to an outside web address and when it gets a certain message it's supposed to disconnect. I tried calling socket.close()
but socket.isConnected()
is still true. No luck searching for an answer
To terminate the accept() ed connection close the accepted socket (what you call connected) by optionally first using shutdown() followed by close () . To then accept a new connection loop right back before the call to accept() , do not go via bind() and listen() again.
Socket programming is a method of communicating between two devices connected to the same network. Two sockets, one on the client and one on the server, interact. An IP address plus a port make up a socket's address. Over the specified port, the server application begins to listen to clients.
Socket programming is a way for devices to communicate over a network. Two sockets communicate, one on the client-side and one on the server-side. A socket's address consists of an IP and a port. The server application starts to listen to clients over the defined port.
isConnected()
only tells you if you made a successful connection to a socket. isClosed()
tells you if you called close()
.
Check out this guys response https://stackoverflow.com/a/3701249/2453771
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With