News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

winsock fun

Started by felipe, March 06, 2019, 10:08:19 AM

Previous topic - Next topic

felipe

I have been working with winsock (more especifically with ws2_32.dll). So i made a little demo-test-unfinished program. Actually 2 programs: the server and the client. So, after both programs establish connections (i'm using tcp), the client send 256 bytes (the classical happy face 02h), then the server shows all those characters received from the client in a simple console. The program works ok and does exactly just that, when both programs are using the localhost address (127.0.0.1).
Now the problem:
I tried this same programs in differents computers using the internet. So i settle the computer with the server: configured the software of the router creating a virtual server in a nat, assigning the port. And in the code the client was addressing the public ip address of the router. But the program dosen't work as expected. The weird issue is that from the client program of one of the computers i run the program using a debbugger, which shows me that's all right, not error codes at all. But in the "server side" (in the other computer) i can't see the characters.
Just an overview:
1)computer running the client program try to reach the public ip of the router in port 80 (i have tried 8080 too). The debbuger shows that connect has no errors neither send (connect and send functions).
2)computer running server is behind a nat, the router has it as virtual server, with a local ip using port 80. The server uses in the code INADDR_ANY as address (but i have tried with the local one and with the public one too).
3)both programs communicate without issues using the same computer, using the localhost address (ip 127.0.0.1).

Any help it's well appreciated... :icon14:

Raistlin

Hail Felipe  8), without much to go on, this sounds like a firewall or port forwarding issue (<- most probable).
Also try using utilities such as Packet Sender, NetCat or similar; to detect and emulate your client - should reveal
whether you have direct server connectivity/communication. Hope this helps - Raistlin
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

felipe

Thanks raistlin i will try some of those tools to make a diagnost.  :icon14:

Raistlin

Any update Felipe ? I'am just interested in network code of any flavor. I've got some free time
towards the end of the month set aside for special projects. Feel free to PM me if you would
like to share thoughts.
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

felipe

i will try to do something today, i will share the results.  :icon14:

Lonewolff

The server PC is likely blocking the incoming traffic. A quick test to confirm this would be to disable the firewall on the PC.

felipe

I have enable the incoming traffic for the server program in the pc server, in the windows firewall, but still no luck. i will add to both programs (client and server) some messages to show the status of the program, to better have and idea of what is happening.
is it possible that is because the client pc has a wifi internet connection?  :idea:

Lonewolff

No the type of connection shouldn't be a problem.

What about disabling the firewall entirely, instead of making exceptions. This will outright tell you if it is a firewall problem or whether you are facing a totally different issue.  :idea:

aw27

Quote from: felipe on March 13, 2019, 11:38:41 PM
I have enable the incoming traffic for the server program in the pc server, in the windows firewall, but still no luck. i will add to both programs (client and server) some messages to show the status of the program, to better have and idea of what is happening.
is it possible that is because the client pc has a wifi internet connection?  :idea:

Download some old Microsoft SDK samples, for example from the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (new SDKs are full of new experimental technologies that obfuscate reality and turn programmers completely dumb).

felipe

Quote from: AW on March 14, 2019, 08:35:53 AM
Download some old Microsoft SDK samples, for example from the Windows SDK for Windows 7 and .NET Framework 3.5 SP1

i prefer not to do that, there are more sources of information about winsock programming. anyway, aren't this samples written in c++?  :idea:

aw27

Quote from: felipe on March 14, 2019, 10:40:18 AM
Quote from: AW on March 14, 2019, 08:35:53 AM
Download some old Microsoft SDK samples, for example from the Windows SDK for Windows 7 and .NET Framework 3.5 SP1

i prefer not to do that, there are more sources of information about winsock programming. anyway, aren't this samples written in c++?  :idea:
There huge sources of information about winsock programming and a basic client/server is expected to always work, something you are having problems with.

felipe

Quote from: AW on March 14, 2019, 06:38:34 PM
a basic client/server is expected to always work, something you are having problems with.

This is not true at all. i mean maybe it will almost always work in the same computer (localhost). but in the internet the issues are very common.  :idea:

Quote from: Ascended on March 14, 2019, 08:20:27 AM
What about disabling the firewall entirely, instead of making exceptions. This will outright tell you if it is a firewall problem or whether you are facing a totally different issue.  :idea:

I will try that too.  :icon14:

TimoVJL

also check if there is a routing problems.
ping ?
netsh interface ipv4 show neighbors ?
May the source be with you

felipe

that was a good idea timo  :icon14:. ping is a simple cmd command/program to test any connection. without the need to re-test the client/server programs, i set up the pc server and in the client pc run the ping command/program with the server ip. i received as output all the packets lost. so the problem is related with the router where i configure the pc server. maybe the ports i have tried are no good ones. i have tried 80, 8080 and 5150. anyone knows of a safe port (that normally works in most cases without having conflicts witho other programs in the computer using port connections) to try out?  :idea:

felipe

and ping doesn't connect successfully either if i completely disable the windows firewall.  :(
But i will keep trying :biggrin:.