sendmessage

i have a question regarding windows networking.

Actually in linux when you call sendmsg or sendpage to send data across
network, the data is queued and the buffer containing the data is freed only
after the ack is received from other side.
Till then that page cannot be freed.

How does this thing happens in windows. I mean what happens when you have
made a sendmsg kind of call in windows. Does it blocks or it returns. When
the page containing the data is freed.

Any pointers or links will also be appreciated

Windows NT and all OSes derived from it (including W2000, XP, etc.) use an
asynchronous I/O model. All I/O operations have 3 phases: starting the
request, notification of completion, and getting the results.

Applications use ReadFile(Ex), WriteFile(Ex), DeviceIoControl, and a few
other functions to start asynchronous requests. All of these take as input
a pointer to an OVERLAPPED structure. The OVERLAPPED structure contains
user-mode state associated with the request, such as whether the request is
complete, its completion status, the number of bytes transferred, etc. Each
active request MUST have a unique OVERLAPPED structure associated with it;
you can reuse an OVERLAPPED structure, but NOT until you know for certain
that a request has been completed.

The I/O subsystem processes the request, and eventually completes it and
notifies the application that the request has been completed. Until that
notification is received, the memory pages that were submitted to the
request are pinned down, cannot be freed, and should not be modified.
(Note: By “freed” I mean the virtual memory descriptors, NOT a heap
allocator’s “free” function, most of which never actually free virtual
memory.)

There are several different means by which the kernel can notify
applications that a request has completed: polling, asynchronous procedure
calls (APCs, which are callbacks), events, and I/O completion ports.

This really isn’t the right place to go into this discussion – this is a
forum for developing device drivers. There are many resources on the
Internet that describe asynchronous I/O. Read the MSDN documentation
thoroughly, especially the entries for ReadFile, WriteFile, DeviceIoControl,
GetOverlappedResult, HasOverlappedIoCompleted, the OVERLAPPED structure, and
CancelIo. And if you’re feeling adventurous, read up on I/O completion
ports, in the sections CreateIoCompletionPort and GetQueuedCompletionStatus.

Also, please note that asynchronous I/O requests initiated from user-mode
are bound to the thread that creates the request. When a thread terminates,
all I/O issued by that thread is cancelled. This does NOT restrict you from
processing the completion notification – you can do that on any thread –
but you must keep this in mind when designing async applications on Windows.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bedanto
Sent: Wednesday, January 04, 2006 1:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] sendmessage

i have a question regarding windows networking.

Actually in linux when you call sendmsg or sendpage to send data across
network, the data is queued and the buffer containing the data is freed only
after the ack is received from other side.
Till then that page cannot be freed.

How does this thing happens in windows. I mean what happens when you have
made a sendmsg kind of call in windows. Does it blocks or it returns. When
the page containing the data is freed.

Any pointers or links will also be appreciated
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com