Click to See Complete Forum and Search --> : how to connect ?


iop
February 18th, 2003, 12:44 AM
assume host A and B are in a localnet 192.168.2.x
host A ip is 192.168.2.1
host B ip is 192.168.2.2
assume host C is on the internet, and it's ip is
also 192.168.2.2 (same with host B)

When i connect to host B or host C,
B and C is not the same,
but their ip address are same!

My Question is:
how to connect host C?

when i connect host B, i write code below:

...
WSADATA wsa;
WSAStartup(MAKEWORD(1,1), &wsa);

int sock = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in sa;
sa.sin_family = AF_INET;
sa.sin_port = htons(80);
sa.sin_addr.s_addr = inet_addr("192.168.2.2");//Host B

connect(sock, (struct sockaddr*)&sa,sizeof(sa));
...

thanx!