🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

winsock UDP not working

Started by
7 comments, last by hplus0603 9 years, 2 months ago

I have 2 app one is a client and the other the server, they use winsock UDP to pass data.

When I run the two app in the same computer, it works, data is transferred.

When I put the client app in another computer, it no longer works , no data arrives.

I open command prompt, only 2 IPv6 listed there work(only when the client and the server run in the same computer)

when I test those 2 IPs and even the rest in the client that is in the other computer none works,

I tested too the IP that appears when I google "whats my IP" and it doesn't work

yes all those IP that I tested are from the computer that is running the server

What is happening here?

Advertisement

Some things you may want to try:

Allow the port to receive data from the outside world:

http://windows.microsoft.com/en-us/windows/open-port-windows-firewall#1TC=windows-7

You may want to just disable your firewall for testing purposes right now to ensure that is or isnt the issue.

Try running the application for the server in "admin" mode as well.

You may also want to download Wireshark to help with your debugging:

https://www.wireshark.org/

I turned off the firewall in both computers and tried again the IPs that I see on command prompt "ipconfig"

none works.

how do you find which IP is the one the server app will accept? because there is the LAN WiFi IP... the google "wats my ip" IP...if I connect a LAN cable to each PC that creates another IP... and in the server app code after I getaddrinfo() socket() and bind() that is another IP I bind

but none works...what IP do you use in your applications?

if you're using gethostbyname() you can just use the network name that you see the other computer as in the windows 'Network'

but for the LAN IP you want the one that's typically starting with 192.168.X.X

The internet IP won't help you unless the computer is directly hooked up to the internet connection, and not a wireless router, OR if you have port forwarding set up so the router directs all traffic coming in on a specific port to the specific machine you want it to go to on your LAN.

I want to send data trough the internet because this is the one that should always work

I am using very similar code to beej UDP example

If the client code is using getaddrinfo() and I want to use the internet connection(through WiFi)

how do I get the IP of the sever computer? you said that google"whats my ip" IP doenst work.... then how?

what code do I need to add for this to work trough the internet?

any links of tutorials?

Hi.

the server app will need a static public ip address. you can link your none static IP address with a DNS some thing like NoIP.com with this set up all clients connect to this dns IP address. The server app needs the IP of the machine running the server and the router needs to have it ports forwared to your server pc and sever app.

Once you get the correct IP your app will again sand as it did on a local net work good luck.

finally I can now send data between two PC inside my home WiFi

I thought that when the server initialized with AF_UNSPEC it could recvfrom() IPv4 and IPv6

so finally it worked with the common IPv4 192.168.0.X

I thought that when the server initialized with AF_UNSPEC it could recvfrom() IPv4 and IPv6


Dual-stack sockets are not universally supported, and may require special handling where it is supported:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb513665%28v=vs.85%29.aspx
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement