|
Overlapped I/O and Event Objects
Windows Sockets 2 introduces overlapped I/O and requires that all transport
providers support this capability. Overlapped I/O follows the model established
in Win32 and can be performed only on sockets that were created through the WSASocket function with the WSA_FLAG_OVERLAPPED flag set.
Note Creating a socket with the overlapped attribute has no impact on whether a
socket is currently in the blocking or nonblocking mode. Sockets created with
the overlapped attribute can be used to perform overlapped I/O doing so does not change the blocking mode of a socket. Since overlapped I/O
operations do not block, the blocking mode of a socket is irrelevant for these
operations.
For receiving, applications use the WSARecv or WSARecvFrom functions to supply buffers into which data is to be received. If one or more
buffers are posted prior to the time when data has been received by the
network, that data could be placed in the user's buffers immediately as it arrives.
Thus, it can avoid the copy operation that would otherwise occur at the time the recv or recvfrom function is invoked. If data is already present when receive buffers are
posted, it is copied immediately into the user's buffers.
If data arrives when no receive buffers have been posted by the application,
the network resorts to the familiar synchronous style of operation. That is, the
incoming data is buffered internally until the application issues a receive
call and thereby supplies a buffer into which the data can be copied. An
exception to this is when the appliation uses setsockopt to set the size of the receive buffer to zero. In this instance, reliable
protocols would only allow data to be received when application buffers had been
posted and data on unreliable protocols would be lost.
On the sending side, applications use WSASend or WSASendTo to supply pointers to filled buffers and then agree to not disturb the
buffers in any way until the network has consumed the buffer's contents.
Overlapped send and receive calls return immediately. A return value of zero
indicates that the I/O operation was completed immediately and that the
corresponding completion indication already occurred. That is, the associated event
object has been signaled, or a completion routine has been queued and will be
executed when the calling thread gets into the alertable wait state.
A return value of SOCKET_ERROR coupled with an error code of WSA_IO_PENDING indicates that the overlapped operation has been successfully initiated and
that a subsequent indication will be provided when send buffers have been
consumed or when a receive operation has been completed. However, for sockets that
are byte-stream style, the completion indication occurs whenever the incoming
data is exhausted, regardless of whether the buffers are full. Any other error
code indicates that the overlapped operation was not successfully initiated and
that no completion indication will be forthcoming.
Both send and receive operations can be overlapped. The receive functions can
be invoked several times to post receive buffers in preparation for incoming
data, and the send functions can be invoked several times to queue multiple
buffers to send. While the application can rely upon a series of overlapped send
buffers being sent in the order supplied, the corresponding completion indications
might occur in a different order. Likewise, on the receiving side, buffers
will be filled in the order they are supplied, but the completion indications
might occur in a different order.
The deferred completion feature of overlapped I/O is also available for WSAIoctl, which is an enhanced version of ioctlsocket.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|