Vikhyath_11

6

Jul 28th, 2024
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package client_sever;
  2. import java.io.*;
  3. import java.net.*;
  4.  
  5. public class Sever {
  6.  
  7.  
  8. public static void main(String[] args) {
  9. try{
  10. ServerSocket ss = new ServerSocket(3306);
  11. Socket s =ss.accept();
  12. DataInputStream dis=new DataInputStream(s.getInputStream());
  13. String str = (String)dis.readUTF();
  14. System.out.println("Message = "+str);
  15. ss.close();
  16. }
  17. catch(Exception e){
  18. System.out.println(e);
  19. }
  20. }
  21.  
  22. }
  23.  
  24.  
  25. package client_sever;
  26. import java.io.*;
  27. import java.net.*;
  28.  
  29. public class client {
  30. public static void main(String[] args) {
  31. try{
  32. Socket s = new Socket("localhost",3306);
  33. DataOutputStream dout=new DataOutputStream(s.getOutputStream());
  34. dout.writeUTF("Hello Server");
  35. dout.flush();
  36. dout.close();
  37. s.close();
  38.  
  39. }
  40. catch(Exception e){
  41. System.out.println(e);
  42. }
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment