Slide 75
Slide 75 text
Our thread I/O loop figures out what to do based on a)
the protocol we provided, and b) what just happened
do {
s = GetQueuedCompletionStatus();
process(s);
} while (1);
void
NTAPI
PxSocketClient_Callback(
PTP_CALLBACK_INSTANCE instance,
void *context,
void *overlapped,
ULONG io_result,
ULONG_PTR nbytes,
TP_IO *tp_io
)
{
Context *c = (Context *)context;
PxSocket *s = (PxSocket *)c->io_obj;
EnterCriticalSection(&(s->cs));
ENTERED_IO_CALLBACK();
PxSocket_IOLoop(s);
LeaveCriticalSection(&(s->cs));
}
PxSocket_IOLoop()
{
...
send_initial_bytes = (
is_new_connection and
hasattr(
protocol,
‘initial_bytes_to_send’,
)
)
}