Reputation: 6072
I want to send a message to a socket
on a gateway(client), and then wait for a message to recieve from a gateway.
While waiting, on other hand I again send a message from server socket
to gateway which is client but on accept()
(ServerSocket) method my connection blocks.
I was wondering is this because of the previous request which was waiting to recieve something by using inputStream
. I used threads
to maintain this and use setReuseAddress()
to do this.
I am not posting a code right now as I just want to know is this logic is fine or is there any logic to handle multiple requests(messages) to be send from a Server-Socket
to a client-Socket and I also dont want to close
the socket because the socket
has to be connected through out the application.
Upvotes: 0
Views: 128
Reputation: 533520
On the client end, you use a Socket object to connect to a server which uses a single ServerSocket. Once the connection is established you will have a Socket at both ends and you can use this Socket to Serversocket connection to send data in either direction. i.e. A single server socket is needed for new connections only.
See: here
Upvotes: 1