473,390 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Multicast Invalid Argument

I'm trying to set a multicast server but I get "Invalid argument" when
setting multicast options.
Below is the code that gives me problems more precisely in
SetSocketOption with the AddMembership name... it exits with a runtime
error telling me "An invalid argument was supplied". Does anyone know
how to fix this?
-------------------------------
public MulticastServer(string IPAddressString)
{
//Create multicast socket
socket=new
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPAddress ip=IPAddress.Parse(IPAddressString);
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.AddMembership,new
MulticastOption(ip));
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.MulticastTimeToLive,2);
IPEndPoint ep=new IPEndPoint(ip,5000);
//socket.Connect(ep);
}

Jan 12 '06 #1
5 5427
Nuno Magalhaes wrote:
I'm trying to set a multicast server but I get "Invalid argument" when
setting multicast options.
Below is the code that gives me problems more precisely in
SetSocketOption with the AddMembership name... it exits with a runtime
error telling me "An invalid argument was supplied". Does anyone know
how to fix this?
-------------------------------
public MulticastServer(string IPAddressString)
{
//Create multicast socket
socket=new
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPAddress ip=IPAddress.Parse(IPAddressString);
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.AddMembership,new
MulticastOption(ip));
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.MulticastTimeToLive,2);
IPEndPoint ep=new IPEndPoint(ip,5000);
//socket.Connect(ep);
}


The docs say:
<quote>
Windows 98, Windows NT 4.0 Platform Note: You must call the Bind
method before using AddMembership as the optionName parameter.
</quote>

Have you tried that?

Jon

Jan 12 '06 #2
I didn't try but now it's another on bind: "The requested address isn't
valid". The IPAddressString is 224.1.2.3 and the code is below:
---------------------------------
socket=new
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPAddress ip=IPAddress.Parse(IPAddressString);
IPEndPoint ep=new IPEndPoint(ip,5000);
socket.Bind(ep);

Jan 12 '06 #3
Nuno Magalhaes wrote:
I didn't try but now it's another on bind: "The requested address isn't
valid". The IPAddressString is 224.1.2.3 and the code is below:
---------------------------------
socket=new
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPAddress ip=IPAddress.Parse(IPAddressString);
IPEndPoint ep=new IPEndPoint(ip,5000);
socket.Bind(ep);


And is the machine you're running on 224.1.2.3?

Jon

Jan 12 '06 #4
No but I fixed it now.
In Ethereal the socket send command will generate entries like this:
Time: 0.0s
Source: 10.154.0.104 SourcePort:5000
Destination: 224.1.2.3 DestPort:5000
Is this normal since my code is written like shown below. Is this a
good programming style?
Thanks for the comments.
-------------------------------
public MulticastServer(string IPAddressString)
{
//Create multicast socket
socket=new
Socket(AddressFamily.InterNetwork,SocketType.Dgram ,ProtocolType.Udp);
IPHostEntry IPHost=Dns.GetHostByName(Dns.GetHostName());
IPAddress ip=IPAddress.Parse(IPHost.AddressList[0].ToString());
IPEndPoint ep=new IPEndPoint(ip,5000);
socket.Bind(ep);

IPAddress ip2=IPAddress.Parse(IPAddressString);
IPEndPoint ep2=new IPEndPoint(ip2,5000);
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.AddMembership,new
MulticastOption(ip2));
socket.SetSocketOption(SocketOptionLevel.IP,Socket OptionName.MulticastTimeToLive,2);
socket.Connect(ep2);
}

Jan 12 '06 #5
Nuno Magalhaes <nu************@hotmail.com> wrote:
No but I fixed it now.
In Ethereal the socket send command will generate entries like this:
Time: 0.0s
Source: 10.154.0.104 SourcePort:5000
Destination: 224.1.2.3 DestPort:5000
Is this normal since my code is written like shown below. Is this a
good programming style?


I'm not sure why it wouldn't be normal - what exactly are you asking
about? The code is fairly reasonable, although I suspect there are
better ways of getting the local endpoint. (I don't do this often
enough to know the best way offhand, I'm afraid.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Owen Jenkins | last post by:
Hello. For years I've been using the DBEngine.CompactDatabase code to make backups of backend databases. But now I've struck a baffling problem where I get an Invalid Argument error. This...
2
by: Pradeep MM | last post by:
Hi Folks, I have a issue in Micosoft Jet 4.0 OLEDB. I am doing a repeated append of data into Microsoft Access 2002 (XP). For a few files I get the error as INVALID ARGUMENT. When I try to...
5
by: Mariame | last post by:
Hi All, I have a datagrid in the select button i write the following code: Response.Write("<script>window.open('new.aspx', New Page',...
1
by: llevi | last post by:
Hi there, My aspnet_state.exe service is failing to start due to an invalid argument. Does anyone know what arguments are required/valid for this service. I am running XP pro, .NET Framework v...
0
by: Greg | last post by:
Hi, creating template1 database in /var/pgsql/data1/base/1... DEBUG: invoking IpcMemoryCreate(size=1081344) FATAL: shmat(id=1179648) failed: Invalid argument What's the problem why is shmat...
2
by: veaux | last post by:
Peeked around here but didn't really see an explanation as to the varied "Invalid Argument" errors that appear in Access sometimes. I'm using Access 2003 and trying to import an Access table of...
4
by: robert | last post by:
On a server the binary (red hat) installed python2.4 and also a fresh compiled python2.5 spits "sem_post: Invalid argument". What is this and how can this solved? Robert ============== ...
1
by: max.aginaga | last post by:
Hi everyone I've come across the following problem: on two different linux machines, both running python 2.5 (r25:51908), I have the same file 'd.dat'. The md5 checksums are the same. Now, on...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.