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.
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. ie A single server socket is needed for new connections only.
See: here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.