Question

I need a little help if someone's got a minute. I've written a web server using IO completion ports, but I am having some trouble sending out large files. Web pages seem to load fine, but during large file transfers, WSASend() fails after a few minutes with error "The specified network name is no longer available."

Right now, my server just closes the associated connection when any overlapped operation fails. Is this the right thing to do? or should I retry failed overlapped operations a few times before I close the socket? I am using tcp/stream sockets.

(fixed) I am also receiving what seems like random 0 byte packets from WSARecv. I am not sure what to make of this, or if the problem is related.(/fixed)

Thanks for any help

edit: now that the server properly handles connections, and has a much more comprehensive log, it seems like Len is right. The client is closing the connection for some reason.

The log:

Initializing Windows Sockets...
Forwarding port 80...
Starting server...
Waiting for incoming connections...
Socket 1128: Client connected.
Socket 1128: Request received
Socket 1128: Sent response
Socket 1128: Error 64: SendChunk() failed. //WSASend()
Socket 1128: Closing connection - GetQueueCompletionStatus == FALSE

so the question is now, why would the client close the connection? It takes anywhere from 2-5 minutes to happen. I have decreased the buffer size to 4098 bytes per send, and only send the next chunk when the first has completed.

Thanks again for any ideas on this.

p.s. I even just implemented a retry function so that it will retry a failed overlapped IO operation five times before giving up....still no luck =(

Was it helpful?

Solution 3

Finally figured it out.

from Rogers Internet Terms of Service:

Without limitation, you may not use (or allow anyone else to use) our Services to:

(xvi) operate a server in connection with the Services, including, without limitation, >mail, news, file, gopher, telnet, chat, Web, or host configuration servers, multimedia >streamers or multi-user interactive forums;

how lame is that? O_o

good news: server works fine =)

edit- called Rogers. They verified that they are cutting me off, and told me that I need a business account to run a web server.

OTHER TIPS

A zero length packet returned from recv indicates client on the other end has closed the connection.
Which answers why your subsequent send to the client failed.

http://www.opengroup.org/onlinepubs/009695399/functions/recv.html

If no messages are available to be received and the peer has performed an orderly shutdown, recv() shall return 0.

Are you doing anything to impose some form of flow control on your data transmission?

If not then you are probably using up resources which is causing the send to fail.

For example, if you are simply issuing LOTS of WSASend() calls one after the other rather than pacing them based on when they complete then each one will use system resources (non-paged pool and/or lock pages which go towards the 'locked pages limit'). You'll then likely eventually fail with ENOBUFS or similar errors.

What you need to do is build a flow control system that works off of the send completions so that you only ever have a known number of sends outstanding at a time.

See these questions for more detail:

Implement a good performing "to-send" queue with TCP

Limiting TCP sends with a "to-be-sent" queue and other design issues

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top