0

I do not know what it is going bad but I am trying to communicate several different boards using MulticastSocket and the receiver seems to keep waiting the message.

I have to transfer 3 different objects through the net from different clients to only one server who will analyze the messages.

The server code:

MulticastSocket escucha = new MulticastSocket(4445);
escucha.joinGroup(InetAddress.getByName("230.0.0.1"));  
byte[] recvBuf = new byte[1000];
DatagramPacket packet = new DatagramPacket(recvBuf,
                                             recvBuf.length);
escucha.receive(packet);
int byteCount = packet.getLength();
ByteArrayInputStream byteStream = new
                              ByteArrayInputStream(recvBuf);
ObjectInputStream is = new
ObjectInputStream(new BufferedInputStream(byteStream));
information nodo = (information)is.readObject();
is.close();

The client code:

ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1000);
ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(byteStream));
os.flush();
os.writeObject(nodo);
os.flush();
//retrieves byte array
byte[] sendBuf = byteStream.toByteArray();
DatagramPacket packet = new DatagramPacket(
      sendBuf, sendBuf.length, InetAddress.getByName("230.0.0.1"), 4445);
 int byteCount = packet.getLength();
 enviador.send(packet);
 os.close();

I launch the server, then I launch the client and the server is blocked in escucha.receive.

Laurel
  • 5,965
  • 14
  • 31
  • 57

0 Answers0