Sign in to follow this  
lomateron

winsock UDP not working

Recommended Posts

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?

Edited by lomateron

Share this post


Link to post
Share on other sites

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/

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Edited by lomateron

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this