News:

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

Main Menu

Connection with another computer, winsock

Started by gelatine1, November 26, 2014, 09:10:36 PM

Previous topic - Next topic

Tedd

The good news is that your server code does work.
It receives what is sent to it - four bytes at a time, but it gets there.

It's actually your client code that's the problem.
Specifically, you're using a local variable in WndProc and assuming it will keep its value. It does not.

What this means is that the contents of 'buffer' (initialised earlier) will no longer be the same when you try to send it (it's in an entirely different invocation of WndProc!) So you're not sending 63, you're sending some random value.
As a quick fix, this will show that it works:

   lea esi,buffer
   mov DWORD PTR [esi],63
   invoke send,sock,esi,4,0


Overall, your code needs many fixes and could be tidied to make it much easier to read (and spot problems.)
Potato2

gelatine1

#16
Could you tell me how do you see that my server code is working ? i run my server in odbg and I put a breakpoint after the WM_SOCKET message (408). then I run the client (which connects to the server) but my server running in odbg never receives any WM_SOCKET message. So that gives me the feeling it is not working but clearly it did work for you ?

Tedd

Load the server in the debugger, set a breakpoint on the call to accept, and another on recv, then run.
Now start your client and the debugger should hit the breakpoint for accept -- so the connection is being made.
Step over, or continue.
Then the recv breakpoint will be hit and you can see what bytes are actually received.
Potato2

gelatine1

I did exactly as you said but the debugger did not hit the breakpoint for accept nor the breakpoint for recv like you said. Is something wrong or weird going on with my computer that doesn't happen for your computer ? Anyone knows what's going wrong maybe ?

gelatine1

Okay, I tried to test using the "telnet 127.0.0.1" command and then I finally had an incoming connection in my server.. :D Then I used the "sen abcd" and I also received a FD_READ message and I received " nes" so a little unexpected but it works :p
Still I am bugged why I can't make a connection between my client and my server.. :/ anyone who can help ?

Tedd

Check windows' firewall isn't blocking connections;
check anti-virus isn't blocking anything;
try using a lower port number (between 1024 and 5000).


You received " nes" because you sent the bytes 's','e','n',' ','a','b','c','d' and then extracted the first four as a dword (dwords are stored 'backwards,') if you took the next four it would be "dcba".
Potato2