 |
|
 |
Hi,
I hava a question, when I send data from this code to j2me my j2me i get no data and when i send data to java i got other port. WHY?
|
|
|
|
 |
|
 |
1. do you have example for c++ code
2. how i can set up in my own pc 2 recievers one send [set up ip etc]
|
|
|
|
 |
|
 |
How would you go about specifying a specific Source address from which to listen for multicast traffic? E.g. I would like to receive multicast traffic from source 192.168.1.1 on multicast address 239.1.1.1:5000 I can find no information here at codeproject, nor msdn on how to do this. Any help would be appreciated... Regards
|
|
|
|
 |
|
 |
Hi, Thanks for your article.
I am able to receive broadcast on my local network.
But as soon as I start receiving broadcast, my system start noise with "BEEP" sound.
note that my system has multiple lan cards and I receive on one of those.
I am receiving NSE broadcast messages.
Any help?
Thanks
Avanish
http://quicksoftpro.com
http://societyonline.in
|
|
|
|
 |
|
 |
Hi!
I try to use the code, to make a host or server, depends on the host exists or not. I try to get a package from the endpoint. If there is none i'll be the host. Please help to get this code working. I test the code like this:
- start one process
- wait 4 sec
- start another process.
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 4567);
IPAddress ip = IPAddress.Parse("224.5.6.7");
s.Bind(ipep);
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 4000);
byte[] b = new byte[1024];
bool isHost = false;
try
{
s.Receive(b);
}
catch (SocketException)
{
isHost = true;
s.Close();
}
if (isHost)
{
Socket ss = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
ss.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 4);
IPEndPoint ipep2 = new IPEndPoint(ip, 4567);
ss.Connect(ipep2);
b = new byte[10];
for (int x = 0; x < b.Length; x++) b[x] = (byte)(x + 65);
Do i need to make another thread here, to send data in an infinite loop?
ss.Send(b,b.Length,SocketFlags.None);
b = new byte[1024];
ss.Receive(b);
string str = System.Text.Encoding.ASCII.GetString(b, 0, b.Length);
Console.WriteLine(str.Trim());
}
else
{
string str = System.Text.Encoding.ASCII.GetString(b, 0, b.Length);
Console.WriteLine(str.Trim());
b = new byte[10];
for (int x = 0; x < b.Length; x++) b[x] = (byte)(x + 65);
s.Send(b,b.Length,SocketFlags.None);
}
|
|
|
|
 |
|
 |
Hi,
I am creating a client application which listens to multiple multicast groups. I have been able to receive messages from all the multicast groups that the client is subscribed to. However, in my application i need to be able to seperate the messages based on which multicast group the message was received on. How can I do that?
Help greatly appreciated.
Thanks
|
|
|
|
 |
|
 |
I'm having exactly the same problem, and it doesn't look like there is an easy answer. In socket.ReceiveFrom there is a ref EndPoint with the destination address, but it is overwritten with the host ip in which you are receiving data.
|
|
|
|
 |
|
 |
Hi,
I downloaded the code and when I launched the send. I got
C:\MyProject\TestApp\App1>mcastSend.exe
MCAST Send on Group: 224.5.6.7 Port: 5000 TTL: 1
An invalid argument was supplied
exit
Any idea what is going on? Thanks in advance.
Kathy
|
|
|
|
 |
|
 |
See message below "First Connect to the Endpoint before setting socket options"
That fixed it for me.
|
|
|
|
 |
|
 |
Hello All,
I am prepare a application design and I would like to know more about multicast in .NET.
There are Multicast senders and receivers in network.
What will happen if two senders need to send messages simultaneously?
Will it compete for the same IP port for outgoing msg at the same time?
Will it only one will success and the other will fail?
Will it be deadlock?
Any Ideas?
Thanks.
modified on Sunday, January 17, 2010 11:39 PM
|
|
|
|
 |
|
 |
Hi,
I have a problem when I have two NICs and two vmware's network adapters.
The socket can not receive multicast packets. I've solved.
IPAddress ipAddressOfNetworkAdapter = IPAddress.parse("192.168.1.28");
int port = 9050;
sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.Bind(new IPEndPoint(ipAddressOfNetworkAdapter , port));
sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(multicastIPAddress, ipAddressOfNetworkAdapter));
|
|
|
|
 |
|
 |
We can definitely do like this
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
public class NewMultiSend
{
public static void Main()
{
Console.WriteLine("Start");
Thread.Sleep(1000);
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.3.23"), 9051);
//IPEndPoint iep = new IPEndPoint(IPAddress.Parse("211.105.212.99"), 9051);
IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("224.100.0.1"), 9050);
server.Bind(iep);
byte[] data = Encoding.ASCII.GetBytes("This is a test message");
server.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("224.100.0.1")));
server.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 50);
server.SendTo(data, iep2);
server.Close();
Console.WriteLine("End");
Console.ReadLine();
}
}
|
|
|
|
 |
|
 |
Hi
How to Create a multicast group
Thanks in advance
Smitha
|
|
|
|
 |
|
 |
I ran the MacastSend.cs on the server & the McastRecv on the client. The send sent me message that it has sent the data but im not able to recieve the the data in the client.
Pls advice...
Thanks
Anand
Anand
|
|
|
|
 |
|
 |
actually i am receving stream data through IP Multicasting in C language. i store that data into a buffer, then i store this data to mpeg file. but when i want to play this file,format not supported. can you tell em what i m missing wht i should do to get proper data so that i could play file. waiting its urgent..............
|
|
|
|
 |
|
 |
The mcastSend has a run-time error on the following line:
s.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership, new MulticastOption(ip));
And from what I tested, this line is only required on the client end. Removing this line and the application works.
|
|
|
|
 |
|
 |
Hi, can you tell me why do client and server not work on localhost? I tried to run them on the same machine, but the client doesn't seem to receive data...
I'm not such an expert about multicast... why this happens? And what can I do to make it work? I need to test it on localhost.
Thanks a lot.
|
|
|
|
 |
|
 |
If it is possible it can detect a certain printer or device with Mac address over the Network?
I have a code which I got from the internet but this one did not return any IP address or MAC address from the IP address I am expecting..
DirectorySearcher srch = new DirectorySearcher();
DirectoryEntry entry = srch.SearchRoot;
string domain = (string)entry.Properties["DC"][0];
DirectoryEntry DomainEntry = new DirectoryEntry("WinNT://" + domain);
DomainEntry.Children.SchemaFilter.Add(this.txtSchemaFilter.Text.Trim()); //"UNIQUE"); //computer dn
// To Get all the System names And Display with the Ip Address
foreach(DirectoryEntry machine in DomainEntry.Children)
{
string[] Ipaddr = new string[3];
Ipaddr[0] = machine.Name;
System.Net.IPHostEntry Tempaddr = null;
this.Status.Text = "Collecting Information..."+Ipaddr[0];
try
{
Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByName(machine.Name);
}
catch(Exception ex)
{
System.Windows.Forms.ListViewItem TempItem1 = new ListViewItem(machine.Name);
this.lstExclude.Items.Add(TempItem1);
continue;
}
System.Net.IPAddress[] TempAd = Tempaddr.AddressList;
foreach(IPAddress TempA in TempAd)
{
Ipaddr[1] = TempA.ToString();
//if(Ipaddr[1].ToString() !="10.25.1.221") {isvalid=false; break;}
isvalid= true;
byte[] ab = new byte[6];
int len = ab.Length;
// This Function Used to Get The Physical Address
int r = SendARP( (int) TempA.Address, 0, ab, ref len );
string mac = BitConverter.ToString( ab, 0, 6 );
Ipaddr[2] = mac;
}
System.Windows.Forms.ListViewItem TempItem = new ListViewItem(Ipaddr);
this.ListHostIP.Items.Add(TempItem);
//### write text file ####
try
{ //System.IO.StreamReader sr = new System.IO.StreamReader();
//System.IO.StreamWriter sw = null;
if(Ipaddr[0]!=null)
{
if(( Ipaddr[1]==null) && ( Ipaddr[2]==null))
sw.Write(" " + Ipaddr[0] +"\r\n");
else if(( Ipaddr[1]!=null) && ( Ipaddr[2]==null))
sw.Write(" " + Ipaddr[0]+ "\t\t " + Ipaddr[1]+"\t\t " + "\r\n");
else
sw.Write("WorkGroup: " + Ipaddr[0]+ "\t\t " + Ipaddr[1]+"\t\t " + Ipaddr[2] +"\r\n");
}
}
catch{}
this.Text = "System Info " + this.ListHostIP.Items.Count.ToString();
Thanks bro.. Hoping for your kind advice..
nice one..
|
|
|
|
 |
|
 |
where this.txtSchemaFilter.Text = "computer"
sorry I forgot this..
nice one..
|
|
|
|
 |
|
 |
Hello
I have used your code on two systems, your code worknig good. But i connects the both systems to the windows server 2003 RAS (and make VPN), RAS assign 10.0.0.10 , 10.0.0.11 ips to both system, and now after connecting, when i want to chat on your application, nothing is receiving on any system this time.
what is the problem? i have configure the RAS rounting service.
please help.
Salman
|
|
|
|
 |
|
 |
Is it possible to get information from the UDP packet in C#. For example, get the source IP, or the source port. I mean the information is available, it's hard to believe that C# would not give us access to it.
I know that in java there is the DatagramPacket class. I don't believe that there is an exact equivalent in C#, but there must be some way to get the info, right?
|
|
|
|
 |
|
 |
Found it:
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
recv = newsock.ReceiveFrom(data, ref sender);
The variable sender will have the information.
|
|
|
|
 |
|
 |
Certain sock options can't be set without first connecting the socket to an endpoint. In some cases no exception is thrown, and the example works...
Better is to use something like the following code (transmitter)
...
ip=IPAddress.Parse(strIpNumber);
Socket socketS=new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(strIpNumber),int.Parse(strPort));
socketS.Connect(ipep);
socketS.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.AddMembership, new MulticastOption(ip));
socketS.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.MulticastTimeToLive, int.Parse(strTtl));
...
happy programming.
-Alphons.
-- modified at 12:54 Thursday 27th October, 2005
|
|
|
|
 |
|
 |
That change makes it work on the same machine also.
|
|
|
|
 |
|
 |
Thanks for a well-written article. I have followed your walk-through
and am having trouble with the sender.
I receive the following error:
An unhandled exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: An invalid argument was supplied
This error happens around the line:
socket.SetSocketOption(SocketOptionLevel.Udp,SocketOptionName.MulticastTimeToLive,
2);
Have you compiled and executed this code recently in VS.NET 2003? I'm
wondering if any changes need to be made.
Thanks for your help.
|
|
|
|
 |