//package comm;
import java.io.*;
import java.net.*;

public class Receiver
{  
    public int evePort;          //snooping Port               
    public Receiver(int evePort)
    {
	this.evePort=evePort;
    }
public Object recvObjFrom()  
    {    try
	{
	    byte[] recvBuf = new byte[5000];
	    DatagramSocket dSock=new DatagramSocket(evePort);
	    DatagramPacket packet = new DatagramPacket(recvBuf, recvBuf.length);
	    dSock.receive(packet);
	    int byteCount = packet.getLength();
	    ByteArrayInputStream byteStream = new ByteArrayInputStream(recvBuf);
	    ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(byteStream));
	    Object o = is.readObject();
	    is.close();
	    dSock.close();
	    return(o);
	}
    catch (IOException e)
	{
	    System.err.println("Exception:  " + e);
	    e.printStackTrace();
	}
    catch (ClassNotFoundException e)
	{ e.printStackTrace(); }
    return(null);  }

    /*    public static void main(String args[])
    {
	Receiver r1=new Receiver(args[0]);
	System.out.println(r1.recvObjFrom());

	} */
}

