Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
3
Indexable
Never
import java.net.*;
import java.io.*;

/**
 *
 * @author HP
 */
public class Server {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try{
            ServerSocket ss = new ServerSocket(6666);
            
            Socket s = ss.accept();
            
            DataInputStream din = new DataInputStream(s.getInputStream());
            DataOutputStream dout = new DataOutputStream(s.getOutputStream());
            BufferedReader  br = new BufferedReader(new InputStreamReader(System.in));
           
            String str1 = "", str2 = ""; 
            
            while(!str1.equals("Bye"))
            {
               str1 = din.readUTF();
               System.out.println("Abid Says : " + str1);
               
               
               str2 = br.readLine();
               dout.writeUTF(str2);
               dout.flush();
               
               
            }
            
            dout.close();
            s.close();  
            ss.close();
        }
        
        catch(Exception e)
        {
            System.out.println(e);
        }
        
    }
    
}