File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes multicast socket problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "multicast socket problem" Watch "multicast socket problem" New topic
Author

multicast socket problem

S lakum
Greenhorn

Joined: Jun 14, 2002
Posts: 9
Hi all,
The multicast socket program below is quite straightfwd. The client sends a msg to a multicast group & the server displays it. My problem is the socket programs are not running on my home machine, but they run fine in my office. I'm behind no firewall. I'm running j2sdk1.4.0_01 version. I cant think why!!!
Can anyone plz help?
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
{
public static void main(String [] arstring)
{
try
{
// Create a multicast datagram socket for receiving IP
// multicast packets. Join the multicast group at
// 230.0.0.1, port 7777.
MulticastSocket multicastSocket = new MulticastSocket(7777);
InetAddress inetAddress = InetAddress.getByName("230.0.0.1");
multicastSocket.joinGroup(inetAddress);
// Loop forever and receive messages from clients. Print
// the received messages.
while (true)
{
byte [] arb = new byte [100];
DatagramPacket datagramPacket = new DatagramPacket(arb, arb.length);
multicastSocket.receive(datagramPacket);
System.out.println(new String(arb));
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
import java.io.*;
import java.net.*;
import java.util.*;
public class Client
{
public static void main(String [] arstring)
{
try
{
// Create a datagram package and send it to the multicast
// group at 230.0.0.1, port 7777.
byte [] arb = new byte [] {'h','e','l','l','o'};
InetAddress inetAddress = InetAddress.getByName("230.0.0.1");
DatagramPacket datagramPacket = new DatagramPacket(arb, arb.length, inetAddress, 7777);
MulticastSocket multicastSocket = new MulticastSocket();
multicastSocket.send(datagramPacket);
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
Thanx
-sunitha
 
jQuery in Action, 2nd edition
 
subject: multicast socket problem
 
Similar Threads
Urgently Help/Guidance Required
Multicast Problem
multicast problems
Writing a class that receive and broadcast at the same time
Simple problem in running a Server class