using System;
using System.Net;
using System.Net.Sockets;
using System.Text;public class UDPMulticastListener
{ private const int Port = 10000;
private static void StartListener()
{
bool done = false;
IPAddress ipAddress = IPAddress.Parse("192.168.0.30");
IPEndPoint EP = new IPEndPoint(ipAddress,Port);
Socket udpserver=new Socket (AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp); try
{
udpserver.Connect(EP);
while (!done)
{
Console.WriteLine("Waiting for data");
byte[] bytes = new byte[1024];
int bytesRec = udpserver.Receive(bytes);
string data=null;
data += Encoding.ASCII.GetString(bytes,0,bytesRec);
Console.WriteLine(data);
if (data.IndexOf("<EOF>") > -1)
{
break;
} } udpserver.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
} public static int Main(String[] args)
{
StartListener();
return 0;
}
}
using System.Net;
using System.Net.Sockets;
using System.Text;public class UDPMulticastListener
{ private const int Port = 10000;
private static void StartListener()
{
bool done = false;
IPAddress ipAddress = IPAddress.Parse("192.168.0.30");
IPEndPoint EP = new IPEndPoint(ipAddress,Port);
Socket udpserver=new Socket (AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp); try
{
udpserver.Connect(EP);
while (!done)
{
Console.WriteLine("Waiting for data");
byte[] bytes = new byte[1024];
int bytesRec = udpserver.Receive(bytes);
string data=null;
data += Encoding.ASCII.GetString(bytes,0,bytesRec);
Console.WriteLine(data);
if (data.IndexOf("<EOF>") > -1)
{
break;
} } udpserver.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
} public static int Main(String[] args)
{
StartListener();
return 0;
}
}
http://www.vckbase.com/document/listdoc.asp?mclsid=9&sclsid=901