dcsimg
non-blocking IO socket BIND error
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rishi_Pande
Posted On:   Tuesday, June 15, 2004 12:36 PM

I am running into a strange problem I have a non-blocking IO server communicating with several clients. This code runs fine when initiated from the command line. When the same code is modified so that it is a class and instantiated from another piece of code, it bombs out with the following error java.net.SocketException: Address already in use at sun.nio.ch.Net.bind(Native Method) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:108) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) at sun.nio.ch.SerevrSocketAdaptor.bind(ServerSocketAdaptor.java:52) at Listener. (Listener.java:41) at Listener.deploy(Listener   More>>

I am running into a strange problem
I have a non-blocking IO server communicating with several clients. This code runs fine when initiated from the command line.
When the same code is modified so that it is a class and instantiated from another piece of code, it bombs out with the following error

			

java.net.SocketException: Address already in use
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:108)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at sun.nio.ch.SerevrSocketAdaptor.bind(ServerSocketAdaptor.java:52)
at Listener. (Listener.java:41)
at Listener.deploy(Listener.java:125)
at testListen.main(testListen.java:8)



The relevant lines of code from Listener.java are

			

ServerSocketChannel server = ServerSocketChannel.open();
ServerSocket sock = server.socket();
InetSocketAddress address = new InetSocket(PORT);
sock.bind(address);
   <<Less

Re: non-blocking IO socket BIND error

Posted By:   Rishi_Pande  
Posted On:   Wednesday, June 16, 2004 12:56 PM

scrap that ... I wa causing two objects of the same class to get instantiated at once. This gave me the bind error.
Anyways, I have run into another problem now where the server does not quit listening on the port after everything is over.
Any 'gotchas' there?
Thanks

Re: non-blocking IO socket BIND error

Posted By:   Rishi_Pande  
Posted On:   Wednesday, June 16, 2004 12:56 PM

scrap that ... I wa causing two objects of the same class to get instantiated at once. This gave me the bind error.
Anyways, I have run into another problem now where the server does not quit listening on the port after everything is over.
Any 'gotchas' there?
Thanks

Re: non-blocking IO socket BIND error

Posted By:   Rishi_Pande  
Posted On:   Tuesday, June 15, 2004 01:27 PM

Forgot to add in the above question, netstat shows nothing listening on the port; netstat shows no running process for the server.
About | Sitemap | Contact