Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have recently started creating chat server, and client programs for my friends and I to use where the server program would be run on my computer, and I would give the client program to my friends to chat etc. when I use the


SockAddr.sin_addr.s_addr = inet_addr("127.0.0.1");

if(connect(sConnect,(SOCKADDR*)(&SockAddr),sizeof(SockAddr))!=0);




section of code it works perfect on my computer, I can connect, and everything works perfectly, but if I change the 127.0.0.1 to my real ip (just for example lets say that its 11.11.11.11) the client program wont connect. (obviously i do this so that the client program wont try to connect to a port on my friends computer where it will be run, but it will connect to one of the ports on mine)


any help would be appreciated

Brett
Posted
Updated 20-Apr-11 12:39pm
v2
Comments
mbue 21-Apr-11 2:51am    
How did you create sConnect?
sConnect = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);??

If you really don't change anything but IP address and make no mistake in the address, I smell firewall!
Check up firewall logs, look at the firewall settings, consider using different protocol…

—SA
 
Share this answer
 
When you say real address do yen mean your computer's IP or your external internet IP?
If you are using your internet address, and have a router then you may need to set up port forwarding on your router, or use upnp to do it for you.
 
Share this answer
 
Ok thanks, I am using my external IP address, so I will have to set up port forwarding thank you for your help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900