import java.io.*;
import java.net.*;
import java.text.DateFormat;
import java.util.*;
public class HandShakeS {
static Scanner in;
static PrintWriter out;
static Socket socket;
public static void main(String args[]) {
try {
ServerSocket s_socket= new ServerSocket(5011);
System.out.println(new Date(System.currentTimeMillis()).toString());
socket=s_socket.accept();
in = new Scanner(socket.getInputStream()); //From Client
out = new PrintWriter(socket.getOutputStream(),true); //To Client
System.out.println("Server listening on port "+socket.getLocalPort()+
"\n sending on port "+socket.getPort()+"\n\n");
System.out.println(new Date(System.currentTimeMillis()).toString());
String input;
input = in.nextLine();
System.out.println(input);
out.println("Hello Client");
in.close();
out.close();
socket.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}