24 bytes

  • HOME
  • Algorithms
    blue
  • Bubble Sort
  • Bucket Sort
  • Insertion Sort
  • Selection Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort
  • Counting Sort
  • Stack
  • Queue
  • Double Linked List
  • Binary Search Tree
  • Towers OF Hanoi

  • Java Programs
    green bullet
  • Download RMI Calculator
  • Download file
  • Clock applet
  • File Upload
  • JDOM Parser
  • Client server
  • Udp Client server
  • Sudoku Solver

  • System Programming
  • Newtwork Sniffer
  • Good Links
    green bullet
  • Free Source Code
  • Top Coder
  • Code Project
  • Learn Today
  • Concept
  • Intresting Programs
    green bullet
  • Prime Number
  • GCD Euclids
  • Permutations


  • Google
     
    Web 24bytes.com



    Simple Client Server Using Java
    
    SERVER
    import java.io.*;
    import java.net.*;
    
    class server {
      Thread t;
      String name;
      try {
        static ServerSocket s = new ServerSocket(8083);
        static Socket socket;
      }
      catch () {}
    
      server(String threadname) {
        name = threadname;
        t = new Thread(name);
        System.out.println("New thread: " + t);
        t.start(); // Start the thread
      }
    
      public void run() {
        while (true) {
          try {
    
            BufferedReader input;
            input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true) {
              String message = input.readLine();
              if (message == null) {
                break;
              }
              System.out.println(message);
            }
          }
          catch (IOException e) {
            System.out.println(e);
          }
        }
      }
    
      public static void main(String[] args) throws UnknownHostException,
          IOException {
        int i = 0;
        while (!s.accept().equals(socket)) {
          new server("a" + i);
        }
      }
    }
    
    
    CLIENT
    import java.net.*;
    import java.io.*;
    
    class client {
      public static void main(String[] args) throws UnknownHostException,
          IOException {
        System.out.println("Hello World!");
        Socket s = new Socket("localhost", 8083);
        String lineToBeSent;
        BufferedReader input;
        PrintWriter output;
        input = new BufferedReader(new InputStreamReader(System.in));
        output = new PrintWriter(s.getOutputStream(), true);
        while (true) {
          lineToBeSent = input.readLine();
          if (lineToBeSent.equals(".")) {
            break;
          }
          output.println(lineToBeSent);
        }
      }
    }
    
    Simple Client Server Using Java
    
    request a code or suggestion


    Email:
    Category


    Google
     
    Web 24bytes.com
    . original template by Aran Down.