S
s_alexander04
Hello!
I have a problem with connecting to IP address using TcpClient class.
When I do:
TcpClient cl=new TcpClient("host_name.com",port);
It's OK, but when I change host-name to an IP address:
TcpClient cl=new TcpClient("aaa.bbb.ccc.ddd",port);
it throws SocketException: "No such host is known".
When I try such thing:
TcpClient cl=new TcpClient(new
IPEndPoint(IPAddress.Parse("aaa.bbb.ccc.ddd"),port));
I get SocketException with a message "The requested address is not
valid in its context"
When this:
TcpClient cl=new TcpClient(new
IPEndPoint(Dns.Resolve("aaa.bbb.ccc.ddd").AddressList[0],port));
I get SocketException with a message "No such host is known". But I
exactly know that it does exist and the IP address and port are
correct.
How should I connect using an IP address? Or maybe is there a solution
that works both for an IP address and a host name? I use VS2003, CF1.
Thanks in advance.
Alexander.
I have a problem with connecting to IP address using TcpClient class.
When I do:
TcpClient cl=new TcpClient("host_name.com",port);
It's OK, but when I change host-name to an IP address:
TcpClient cl=new TcpClient("aaa.bbb.ccc.ddd",port);
it throws SocketException: "No such host is known".
When I try such thing:
TcpClient cl=new TcpClient(new
IPEndPoint(IPAddress.Parse("aaa.bbb.ccc.ddd"),port));
I get SocketException with a message "The requested address is not
valid in its context"
When this:
TcpClient cl=new TcpClient(new
IPEndPoint(Dns.Resolve("aaa.bbb.ccc.ddd").AddressList[0],port));
I get SocketException with a message "No such host is known". But I
exactly know that it does exist and the IP address and port are
correct.
How should I connect using an IP address? Or maybe is there a solution
that works both for an IP address and a host name? I use VS2003, CF1.
Thanks in advance.
Alexander.