Saturday, January 14, 2012

10b Server Application


import java.net.*;
import java.io.*;
class Server
  {
    public static DatagramSocket ds;
    public static byte buffer[]=new byte[1024];
    public static int clientport=790,serverport=789;
    public static void main(String args[])throws IOException
     {
       ds=new DatagramSocket(serverport);
       System.out.println("\t\t*****************\n\t\t**SEVER PROGRAM**\n\t\t*****************\nPRESS ctrl+C TO COMEPROMPT");
       while(true)
        {
  DatagramPacket p=new DatagramPacket(buffer,buffer.length);
  ds.receive(p);
  String psx=new String(p.getData(),0,p.getLength());
  System.out.println(psx);
        }

     }
  }


No comments:

Post a Comment