Problem with IP address converstion from a string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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);
 
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?
 
Back
Top