void Socket::IOControl(DWORD dwIoControlCode, const BufferPtr &inBuffer, const BufferPtr &outBuffer) { DWORD bytesReturned; if (0 != WSAIoctl(hSocket, dwIoControlCode, inBuffer->Pointer(), inBuffer->Size(), outBuffer->Pointer(), outBuffer->Size(), &bytesReturned, 0, 0)) { throw Win32Exception("WSAIoCtl"); } outBuffer->Resize(bytesReturned); }
AsyncResultPtr Socket::BeginSend(const BufferPtr &buffer, AsyncCallback callback, const ObjectPtr &asyncState) { AsyncResultPtr asyncResult(this, buffer, asyncState, Nothing, callback); asyncResult->AddRef(); WSABUF wsabuf; wsabuf.buf = (char *)buffer->Pointer(); wsabuf.len = buffer->Size(); DWORD flags = 0; if (0 != WSASend(hSocket, &wsabuf, 1, 0, flags, asyncResult.operator ->(), 0) && WSAGetLastError() != WSA_IO_PENDING) { asyncResult->Release(); throw Win32Exception("WSASend"); } return asyncResult; }