Hi guys,
  thanks to everybody for answering my previous question.
Can anybody help me out with this. it might be a bit off
topic but has images in it.
    I am in urgent need of a solution to my problem. I am
working on a multicast project wherein the sender is
sending an image file and the receiver(client) is
downloading bytes from the multicastsocket and displaying
it on a JFrame. I am not working with applets here because
i would initially be developing it as an application. My
sender is in C. it is successfully sending frames(256) of
the image. on the receiving i have written a Java client,
the code for which has been pasted below. I am able to
build the socket but not able to receive packets. somebody
please help me. I can post the C code also if u want. I
have posted comments where the problem lies.

import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import java.net.*;


public class SecondTest extends JFrame {
    MulticastSocket msocket;
    InetAddress addr;
    final static int PORT=12345;
    DatagramPacket packet;
    Image image;
    public SecondTest(String tes) {
        setTitle(tes);
        byte[] buffer = new byte[256];
try {
    addr = InetAddress.getByName("225.0.0.37");
    System.out.println("address is" + addr);

    msocket = new MulticastSocket(PORT);
    msocket.joinGroup(addr);
    System.out.println("Created Socket" + msocket);
    /* The code does not work beyond this.*/
    packet = new DatagramPacket (buffer, buffer.length);
    msocket.receive(packet);
   /* no packets are being received and hence the following
statement is not printed*/
    System.out.println("receiving packet. Size = " +
packet.getLength());


   }
catch (Exception e) {
    System.out.println("Error!");
    e.printStackTrace();
}
System.out.println("The length of buffer is = " +
buffer.length);
        image =
Toolkit.getDefaultToolkit().createImage(packet.getData());
        MediaTracker tracker = new MediaTracker(this);
        tracker.addImage(image, 1);
        try {
            tracker.waitForAll();
        } catch (Exception e) {
            image = null;
            System.err.println("Can't load image");
        }
        setSize(500, 400);
        setBackground(Color.yellow);
        setVisible(true);
    }

    public void paint(Graphics g) {
        if (image != null) {
            g.drawImage(image, 50, 50, null);
        }
    }

   }




__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to