Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. import java.io.DataOutputStream;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.net.ServerSocket;
  5. import java.net.Socket;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         try {
  10.             int playerCount = args[0] == null ? 50000 : Integer.parseInt(args[1]);
  11.             ServerSocket listenerSocket = new ServerSocket(43594);
  12.             while (listenerSocket.isBound()) {
  13.                 Socket sock = listenerSocket.accept();
  14.                 InputStream is = sock.getInputStream();
  15.                 DataOutputStream dos = new DataOutputStream(sock.getOutputStream());
  16.                 if (is.read() == 16) {
  17.                     dos.writeShort(playerCount);
  18.                 } else {
  19.                     System.out.println("Unsupported request");
  20.                 }
  21.             }
  22.         } catch (IOException e) {
  23.             e.printStackTrace();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement