Question

I am beginner of socket programming. I want to open "closed port", i can listening port like

serverSocket = new ServerSocket(port);

What is the difference between listening / open port and how do i open port. Anyone can help?

Was it helpful?

Solution

You can't open a port with Java. It's a firewall operation. You can listen at a port, which your code sample exemplifies, or you can connect to it, by constructing a new Socket(...) with the appropriate hostname:port parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top