views:

66

answers:

2

I'm writing a simple proxy (more a packet logger) for an online game in C#. The basic Login process is like this:

Client->Server: Login Packet - My proxy receives the packet, displays it and sends it to the server.

Server->Client: Connected! Packet - My proxy again receives the packet, it also displays it again but when trying to send it to the client, it says:

"A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied."

My code: http://lesderid.pastebin.com/NkEy7qQp

+1  A: 
171: listenSocket.Send(RecvBuffer2);

You shouldn't be trying to send on this listening socket. You need to send on the socket that was created with EndAccept(). (winSock2 in your code - but you would need to scope it differently.)

Mark H
Thank you! Answer accepted.
lesderid
+1  A: 

Listening TCP sockets have but one function - accept client connections. The connection will occupy a new socket descriptor, i.e. a new socket will be created for each new client connection (and in C that's what accept(2) system call returns).

You cannot send(2) or recv(2) data on listening sockets.

Nikolai N Fetissov
Thank you for this explanation, I understand it better now. I won't select this as the answer though, for the reason that it doesn't directly solve my problem.
lesderid