Re: WSASend()
From: Alun Jones [MSFT] (alunj_at_online.microsoft.com)
Date: 10/12/04
- Next message: Alun Jones [MSFT]: "Re: IO Completion ports and closesocket()"
- Previous message: Alexander Nickolov: "Re: WSASend()"
- In reply to: Alexander Nickolov: "Re: WSASend()"
- Next in thread: Martin Wan: "Re: WSASend()"
- Reply: Martin Wan: "Re: WSASend()"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 12 Oct 2004 13:11:41 -0700
"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:eSOq2AIsEHA.808@TK2MSFTNGP12.phx.gbl...
> There's a glaring error in the sample code - the socket is not
> created as overlapped, hence no overlapped I/O is happening.
> Replace the call to socket() with WSASocket and use the
> WSA_FLAG_OVERLAPPED flag.
No, that's not going to help - go and look at the documentation for
socket(), and you will see that it produces (has to produce) an overlapped
socket.
> Note the sample is very
> inefficient - do not base your real code on it.
Many samples are designed to show how to use something, and the reason
developers get paid the big bucks is that they go from "how to" to "how best
to". A sample in a help file is necessarily going to be short, and may
gloss over many examples of use that you might want to see. Network
programming, particularly, is not an easy subject explained in a few lines -
you would do best to find a book that suits your level of interest. I'm
particularly partial to "Network Programming for Microsoft Windows" by Jones
(no relation) and Ohlund.
> The reason for
> overlapped I/O is so you can service multiple sockets efficiently.
> However, the sample code blocks for each send/receive until
> completion (and has bugs in its main loop too - does not resume
> receiving for example).
I have submitted a request to sdkfdbk@microsoft.com (the link is at the
bottom of the page referred to by the OP, see "What did you think of this
topic?") for them to take a look. I'll let them address how it should be
fixed, but where I'd start is by looking at the value of DataBuf.len before
WSASend. Initialising buffer to zero (as the OP suggested) is not likely to
help, unless you really want to send a few thousand null bytes.
Thank you for bringing this to our attention.
Alun.
~~~~
- Next message: Alun Jones [MSFT]: "Re: IO Completion ports and closesocket()"
- Previous message: Alexander Nickolov: "Re: WSASend()"
- In reply to: Alexander Nickolov: "Re: WSASend()"
- Next in thread: Martin Wan: "Re: WSASend()"
- Reply: Martin Wan: "Re: WSASend()"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|