Forums Register Login

How to terminate NIO Server Connection?

+Pie Number of slices to send: Send
Hi everybody,

I have really problem, i try to terminate the server connection from listing on specific port but it is still listing and i get these exceptions when i close the connection.

i am using JDK1.6.

Close Connection code:


Exceptions when Close Connection:


I desperately need help.

thanks.
+Pie Number of slices to send: Send
The way I read the JavaDocs for java.nio.channels.ClosedChannelException, this indicates that "an attempt is made to invoke or complete an IO operation upon a channel that is closed or at least closed to that operation."

Are there other Threads that may be using this port?

Bill
+Pie Number of slices to send: Send
It's not at all surprising that "accept" would throw an exception if you close the socket channel it's trying to use -- sounds like expected behavior. Either wrap your calls to accept() in a try/catch block to handle shutdown, or don't shut down the socket while accept() is running -- and of course don't call accept() again after the socket has been closed!
+Pie Number of slices to send: Send
Hi Bill,

first thanks for your answer, yes there are another thread working but i do not know if it uses the same port.

I am using this sample code (only the server code) from this web site Click here

Thanks bill.
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1964 times.
Similar Threads
iText Acro Form SocketException
tomcat Threads not closing on shutdown
problem setting up the validations in the pages
how to fix error: Communications link failure ?
Cant run my applet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:12:07.