471,610 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Problem with IP address converstion from a string

I'm getting a connection error when I used the following code to connect to a
server on our LAN with IP address. Can someone take a look and tell me if
you see something wrong? I'm just getting back error message that it's time
out and no connection was made.
Thanks, Alpha

string ServerIP = "192.168.7.1"
m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
String ServerIP = server;
String szPort = "22333";
int alPort = System.Convert.ToInt16 (szPort,10);

System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(ServerIP);
System.Net.IPEndPoint remoteEndPoint = new
System.Net.IPEndPoint(remoteIPAddress, alPort);
m_socClient.Connect(remoteEndPoint);
Dec 27 '05 #1
1 1931
Alpha,

From what I can tell, this isn't an issue with parsing the IP address
from a string. You seem to have the port and the ip address converted
correctly.

Are you sure that the port 22333 on IP address 192.168.7.1 is valid?
Can you telnet into it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I'm getting a connection error when I used the following code to connect
to a
server on our LAN with IP address. Can someone take a look and tell me if
you see something wrong? I'm just getting back error message that it's
time
out and no connection was made.
Thanks, Alpha

string ServerIP = "192.168.7.1"
m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
String ServerIP = server;
String szPort = "22333";
int alPort = System.Convert.ToInt16 (szPort,10);

System.Net.IPAddress remoteIPAddress =
System.Net.IPAddress.Parse(ServerIP);
System.Net.IPEndPoint remoteEndPoint = new
System.Net.IPEndPoint(remoteIPAddress, alPort);
m_socClient.Connect(remoteEndPoint);

Dec 27 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Angelos Karantzalis | last post: by
3 posts views Thread by Mark | last post: by
reply views Thread by Pallav | last post: by
4 posts views Thread by Stephen | last post: by
2 posts views Thread by Christopher Weaver | last post: by
5 posts views Thread by Jason Huang | last post: by
11 posts views Thread by Daylor | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

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.