Ejemplo n.º 1
0
	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);
	}
Ejemplo n.º 2
0
void OnReceive(const AsyncResultPtr &asyncResult)
{
	try {
		SocketPtr acceptSocket = asyncResult->asyncState;
		BufferPtr buffer = asyncResult->buffer;
		size_t size = acceptSocket->EndReceive(asyncResult);
		if (size != 0) {
			buffer->Resize(size);
			acceptSocket->BeginSend(buffer);
			acceptSocket->BeginReceive(BufferPtr(8192, NoRebindTag()), &OnReceive, acceptSocket);
		} else {
			acceptSocket->BeginDisconnect();
		}
	} catch (const std::exception &) {
	}
}