server.java 817 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import java.io.*;
  2. import java.net.Socket;
  3. import java.net.ServerSocket;
  4. public class server
  5. {
  6. public static void main(String arg[])throws IOException
  7. {
  8. try
  9. {
  10. Socket sock;
  11. ServerSocket sockserve;
  12. BufferedReader br;
  13. BufferedReader x;
  14. InputStream in;
  15. OutputStream out;
  16. PrintStream pr;
  17. String str;
  18. sockserve=new ServerSocket(3336);
  19. x=new BufferedReader(new InputStreamReader(System.in));
  20. sock=sockserve.accept();
  21. in=sock.getInputStream();
  22. out=sock.getOutputStream();
  23. br=new BufferedReader(new InputStreamReader(in));
  24. pr=new PrintStream(out,true);
  25. while(true)
  26. {
  27. str=x.readLine();
  28. System.out.println(""+str);
  29. pr.println(str);
  30. System.out.println("From client"+br.readLine());
  31. }
  32. }
  33. catch(Exception e)
  34. {
  35. System.out.println(""+e);
  36. }
  37. }
  38. }