What would this statement do:
ServerSocket ss=new ServerSocket(4646);
Please explain in layman terms.
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.
The statement effectively tells the JVM to listen on port specified (4646) for incoming connections. By itself it doesn’t mean anything since you will have to take incoming connections to that port and use them to build normal
Socketobjects that will be then used for ingoing/outgoing data.You could say that the
ServerSocketis the object through which real TCP sockets between clients and the server are created. When you create it, the JVM hooks to the operating system telling it to dispatch connections that arrive on that port to your program.What you typically do is something like:
So that you will accept incoming connections and open a thread for them.