Answers for "how to listen to a port in java"

0

how to listen to a port in java

int portNumber = Integer.parseInt(args[0]);

try ( 
    ServerSocket serverSocket = new ServerSocket(portNumber);
    Socket clientSocket = serverSocket.accept();
    PrintWriter out =
        new PrintWriter(clientSocket.getOutputStream(), true);
    BufferedReader in = new BufferedReader(
        new InputStreamReader(clientSocket.getInputStream()));
) {
Posted by: Guest on November-12-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language