Advertisement
NB52053

Socket__ServerOnly

Aug 3rd, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package sa;
  2.  
  3. import java.net.*;
  4. import java.io.*;
  5.  
  6. public class Server{
  7.  
  8.     public static void main(String[] args) throws IOException {
  9.  
  10.     try{
  11.         ServerSocket  ss=new ServerSocket(5432);
  12.         System.out.println("listening mode");
  13.         Socket s=ss.accept();
  14.         System.out.println(("request accepted"));
  15.         OutputStream os=s.getOutputStream();
  16.         InputStream is=s.getInputStream();
  17.         PrintWriter pw=new PrintWriter(os);
  18.  
  19.         pw.println("hello");
  20.         pw.println("hi");
  21.         pw.flush();
  22.         pw.flush();
  23.         while(true){
  24.            
  25.         }
  26.         pw.close();
  27.         s.close();
  28.  
  29.  
  30.         }
  31.  
  32.         catch(IOException e)
  33.         {
  34.             e.printStackTrace();
  35.  
  36.  
  37.         }
  38.  
  39.     }
  40.  
  41.  
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement