How do I create a TCP socket in Java?
How do I create such a TCP connection that it terminates only when I tell it to otherwise it remains open?
How do I use keepalives to know whether the server or client is still available?
Please Help!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
http://docs.oracle.com/javase/tutorial/networking/sockets/index.html
They will remain open until either you or the other end closes it.
That is up to you. You can send different messages, one of which is a heartbeat which tells the other end you are alive.
A common thing to do if you are sending binary messages is to send the length as an unsigned short or int value. I use a message of “length” 0 as a heartbeat.