I am facing a little problem with sockets.
This method takes about 100ms or even more, depends on the server. socket.connect(dest);
Then I am communicating through DataInput/Output streams to a sofisticated software, so there is query phase, handshake phase, login request phase etc.
Is there any way I can "reset" the datastream from handshake phase so the server forgets everything and the socket would be again in the first phase without doing socket.connect(dest); again ?
Thanks.
这完全取决于协议,与套接字本身无关。
There is nothing stopping you from passing as many messages back and forth through a socket; except maybe your protocol (or the lack of a clearly defined one) if it doesn't indicate where a message starts/ends.
When using a DataInput/OutputStream you could just define a Message class containing whatever data and both sides would just run in an infinite loop reading a Message, processing and possibly generating a response message.
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.