IP addresses

B

bernardpace

Hi,

I am trying to create an IPAddress and pass it to the IPEndPoint
constructor.

IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, portNo);

When running that code the following error is being given on the 2nd
line:
"An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in system.dll

Additional information: Specified argument was out of the range of
valid values."

Can someone help me out
Thanks in Advance
 
A

Andrew

IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, portNo);

What is portNo set to? Did you possibly forget to initialize it to your
desired port number?
 
B

bernardpace

Yes, infact it was a problem of port number. The port number that I
was passing was larger than the range expected.

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top