programming-examples/java/Numerical_Problems/java program to make a socket displaying message to a single client.java
2019-11-15 12:59:38 +01:00

18 lines
578 B
Java

import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
public class BeerServer {
public static void main(String args[])
throws Exception {
ServerSocket ssock = new ServerSocket(1234);
System.out.println("Listening");
Socket sock = ssock.accept();
ssock.close();
PrintStream ps = new PrintStream(sock.getOutputStream());
for (int i = 10; i >= 0; i--) {
ps.println(i + " from Java Source and Support.");
}
ps.close();
sock.close();
}
}