*
* *
*
scene.org
Log in:
login for 1 year
No account? register here

Scene.org is hosted and supported by:
Scene.org is sponsored by:
* forum - #coders

*
Topic:  Error after 2 times calling recv()
* Posted by Fillbert Friday 6 January 2006 - 23:06 
problem:

when i recieve data via recv(...) then it works for two calls. after that i get WSAECONNABORTED.

i know the description is very small, but perhaps someone has an idea where to start...

Thx

Fillbert / Creative Mind

* Posted by Danzig Tuesday 10 January 2006 - 20:50 
are you using winsock-events??
maybe your are just calling recv too f**king
often?

Danzig

* Posted by Fillbert Tuesday 10 January 2006 - 21:51 
i have to console programs. one which send data (client) and one which recieve data (server). client send data in 1000 byte blocks. server get first block, also 1000 bytes and send it directly back. after recieving 2nd block, at server, i get the WSAECONNABORTED.

return value of recv for the first two times are 1000, and then 10053 (WSA....ABORTED)

* Posted by Danzig Tuesday 10 January 2006 - 22:00 
Again: are you using winsock-events or are you polling?

Have you tried to change the ports on the sockets?

Are you programming "plain winsock2-api" or are you using any "proprietary" framework (f.e. mfc or vcl)??

May you should post your code(snippet).

Danzig

* Posted by Fillbert Tuesday 10 January 2006 - 22:10 
im using plain winsock2 api and im polling...

an other question:

SOCKET listenSocket;
...
acceptSocket = accept(listenSocket,NULL,NULL);
...
StartThread(acceptSocket);
...

after acceptSocket != SOCKET_ERROR is listenSocket still valid ???

and a second one:
can i send back data from server while reading data which are in queue to the server ?

Thx Fillbert

[Post edited by Fillbert on Tuesday 10 January 2006 - 22:19]


* Posted by Danzig Tuesday 10 January 2006 - 22:22 
polling is no good. i asume you are recv() too early causing the connectionabort! 10053 is a typical "Software Caused Connection Abort"-message when you end the connection the "hard" way (not disconnecting).

you should try winsock-events.

about the listenSocket. It should stay valid coz its your "listener"-socket, listening for incoming connections! with accept() you create a new socket for the incoming connection. the listener is just the "base-entrypoint".

but (problem polling) msdn sayz:

The accept function can block the caller until a connection is present if no pending connections are present on the queue, and the socket is marked as blocking. If the socket is marked as nonblocking and no pending connections are present on the queue, accept returns an error as described in the following. After the successful completion of accept returns a new socket handle, the accepted socket cannot be used to accept more connections. The original socket remains open and listens for new connection requests.

* Posted by Fillbert Tuesday 10 January 2006 - 22:27 
i work with threads...

i have a server thread which listen via accept() and if a connection is coming in then it creates a thread which handles the connection.

do you think this is okay ?

Thx Fillbert

* Posted by Danzig Tuesday 10 January 2006 - 22:35 
good question ;)

the discussions about the pros/cons of blocking/nonblocking sockets is like the war of roses in some forums :}

i myself prefer nonblocking sockets.

i just create an event object and wait for it and then handle the incoming events (connect, read, etc.). but then i put the whole async-serversocket in a seperate thread, that was always enuff for my demands.

the real question is: why are you using plain winsock-api?? just for education needs?

* Posted by Fillbert Tuesday 10 January 2006 - 23:21 
hope its more efficent then higher level api...

*