import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Enumeration;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.BufferedWriter;

public class Server {

    private static String SERVERIP;
   

    public static void main(String[] args) throws IOException
    {
        String clientSentence;
        

        ServerSocket welcomeSocket = new ServerSocket(8889);
        SERVERIP = "10.242.14.54";
       
        System.out.println("Connected and waiting for client input!\n");
        System.out.println("Listening on IP: " + SERVERIP +"\n\n");

        while(true)
        {
            Socket connectionSocket = welcomeSocket.accept();

            BufferedReader inFromClient =
                    new BufferedReader(new InputStreamReader(
                            connectionSocket.getInputStream()));

            
			
            clientSentence = inFromClient.readLine();
           
            String ip = connectionSocket.getInetAddress().toString().substring(1);
           
            System.out.println("In from client ("+ip+"): "+clientSentence);

            if(clientSentence != null)
            {
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(connectionSocket.getOutputStream())),true);
				//out.println(str);
		if(clientSentence.equals("1a")||clientSentence.equals("2a"))
			out.println("a2400024000102500");
		if(clientSentence.equals("1b")||clientSentence.equals("2b"))
			out.println("b255447");
		if(clientSentence.equals("1c")||clientSentence.equals("2c"))
			out.println("c155059150195043");
		if(clientSentence.equals("start"))
			out.println("started");
		if(clientSentence.equals("start1"))
			out.println("started");
		if(clientSentence.equals("m"))
				out.println("m10044003");
		else
			System.out.println(clientSentence+"nnnnnnnnnn" );
               
               
            }

        }
    }
   
    
}

