*)&lpOverlapped, INFINITE); if (!...\n"); shutdown(lpOverlapped->m_sClient, SD_BOTH); closesocket(lpOverlapped...buf.buf = lpOverlapped->m_pszBuf; buf.len = dwNumberOfBytes; lpOverlapped...->m_dwFlags = 0; WSASend(lpOverlapped->m_sClient, &buf, 1, &lpOverlapped->m_dwNumberOfBytesRecv..., lpOverlapped->m_dwFlags, &lpOverlapped->m_overlapped, NULL); } } } return
lpOverlapped);BOOL WriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD...lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);在同步模式下,ReadFile和WriteFile函数会阻塞调用线程,直到指定的字节数被读取或写入...lpOverlapped);在调用DeviceIoControl时,dwIoControlCode参数指定了要执行的IOCTL操作,lpInBuffer和lpOutBuffer参数指向输入和输出数据缓冲区...这个函数的原型如下:BOOL GetOverlappedResult( HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred...WaitCommEvent函数的原型如下:BOOL WaitCommEvent( HANDLE hFile, LPDWORD lpEvtMask, LPOVERLAPPED lpOverlapped
) lpPipeInst, (LPOVERLAPPED_COMPLETION_ROUTINE) CompletedReadRoutine); // 如果写失败了,就断开连接...) lpPipeInst, (LPOVERLAPPED_COMPLETION_ROUTINE) CompletedWriteRoutine); } // 如果读失败了...) lpPipeInst, (LPOVERLAPPED_COMPLETION_ROUTINE) CompletedReadRoutine); // 如果写失败了,就断开连接...lpOverlapped, __in_opt LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ); 完成例程 VOID...lpOverlapped ); 这样设计,就可以达到一个很重要的目的:在完成例程中获取“读/写”的数据。
lpOverlapped ); 参数: hDevice [in] 需要执行操作的设备句柄。...如果lpOverlapped为NULL,则lpBytesReturned不能为NULL。...如果lpOverlapped不为NULL,则lpBytesReturned可以为NULL。 如果此参数不为NULL并且操作返回数据,则在重叠操作完成之前,lpBytesReturned是无意义的。...,则忽略lpOverlapped。...在这种情况下,lpOverlapped必须指向包含事件对象句柄的有效OVERLAPPED结构。 否则,该功能将以不可预知的方式失败。
lpOverlapped ); sListenSocket: 监听套接字 sAcceptSocket:该参数是一个SOCKET的句柄,一旦连接成功建立,那么会使用该SOCKET作为通信的SOCKET...lpOverlapped, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, DWORD dwFlags); 这个函数主要工作在TCP协议上 hSocket...lpOverlapped, DWORD dwFlags ); 这个函数不但可以在面向连接(面向流)式的协议(TCP)上工作,还可以在无连接式的数据报协议(UDP)上工作,而TransmitFile...BOOL DisconnectEx( SOCKET hSocket, LPOVERLAPPED lpOverlapped, DWORD dwFlags, DWORD reserved ); hSocket...:表示将要被回收的SOCKET lpOverlapped:重叠IO所使用的结构 dwFlags:它是一个标志值,表示是否需要回收SOCKET,如果为0则表示不需要回收,此时它的作用与closesocket
lpOverlapped);lpBuffer:指向用于存储读取数据的缓冲区的指针。...lpOverlapped:指向OVERLAPPED结构的指针,用于异步操作。4.2 WriteFile用于向串口写入数据。...HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED...lpOverlapped);参数与ReadFile类似,用于异步写入操作。...函数原型如下:BOOL WaitCommEvent( HANDLE hFile, LPDWORD lpEvtMask, LPOVERLAPPED lpOverlapped);6.
lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED...lpOverlapped ); hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize,...LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped...指定了一个操作,该操作不需要处理输出数据,那么这个参数设为NULL nOutBufferSize:haha,别说你不知道什么什么意思,pass lpBytesReturned:实际输出数据的bytes lpOverlapped
HANDLE CompletlonPort, DW0RD dwNumberOfBytesTrlansferred, DWORD dwCompletlonKey, LPOVERLAPPED... lpoverlapped, ); 其中,CompletionPort参数指定想向其发送一个完成数据包的完成端口对象。...而就dwNumberOfBytesTransferred,dwCompletionKey和lpOverlapped这三个参数来说.每—个都允许我们指定—个值,直接传递给GetQueuedCompletionStatus
HANDLE hIocp = (HANDLE)lpParam; DWORD dwReasonId = 0; HANDLE hJob = NULL; OVERLAPPED *lpOverlapped...bLoop) { BOOL bSuccess = GetQueuedCompletionStatus(hIocp, &dwReasonId, (PULONG_PTR)&hJob, &lpOverlapped...JOB_OBJECT_MSG_END_OF_PROCESS_TIME: { DWORD dwProcessID = (DWORD)lpOverlapped...case JOB_OBJECT_MSG_NEW_PROCESS: { DWORD dwProcessID = (DWORD)lpOverlapped...JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: { DWORD dwProcessID = (DWORD)lpOverlapped
, //完成端口对象句柄 LPDWORD lpNumberOfBytes,//取得IO操作期间 PULONG_PTR lpCompletionKey, LPOVERLAPPED...* lpOverLapped, DWORD dwMilliseconds );
FileIOCompletionRoutine( __in DWORD dwErrorCode, __in DWORD dwNumberOfBytesTransfered, __in LPOVERLAPPED...lpOverlapped ); 第一个参数是一个错误码,当IO操作发生错误时可以通过这个参数获取当前错误原因 第二个参数是当前IO操作操作的字节数 第三个参数是一个OVERLAPPED结构...lpParam); VOID CALLBACK FileIOCompletionRoutine(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED...lpOverlapped); int _tmain(int argc, _TCHAR* argv[]) { TCHAR szAppPath[MAX_PATH] = _T(""); GetAppPath...lpOverlapped) { LPIOCP_OVERLAPPED pIOCPOverlapped = (LPIOCP_OVERLAPPED)lpOverlapped; //释放对应的内存空间
WSAGetOverlappedResult来确定IO操作执行的结果,该函数原型如下: BOOL WSAGetOverlappedResult( SOCKET s, LPWSAOVERLAPPED lpOverlapped...; void CALLBACK CompletionROUTINE(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped,...\n", inet_ntoa(AddrClient.sin_addr), ntohs(AddrClient.sin_port)); LPOVERLAPPED_COMPILE lpOc...return 0; } void CALLBACK CompletionROUTINE(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped..., DWORD dwFlags) { LPOVERLAPPED_COMPILE lpOc = (LPOVERLAPPED_COMPILE)lpOverlapped; if (0 !
HANDLE, LONG, LONG *, DWORD); typedef BOOL (WINAPI * SFILEREADFILE)(HANDLE, VOID *, DWORD, DWORD *, LPOVERLAPPED... BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead = NULL, LPOVERLAPPED... lpOverlapped = NULL); // Adds another listfile into MPQ.
这个函数的原型如下:BOOL WaitCommEvent( HANDLE hFile, LPDWORD lpEvtMask, LPOVERLAPPED lpOverlapped...);hFile参数是串口的句柄,lpEvtMask参数是一个指向DWORD的指针,用于接收发生的事件类型,lpOverlapped参数是一个指向OVERLAPPED结构的指针,用于异步操作。
bWatchSubtree, DWORD dwNotifyFilter, LPDWORD lpBytesReturned, LPOVERLAPPED...lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ); 其中: hDirectory:要监视的目录的句柄...lpOverlapped:用于异步操作的 OVERLAPPED 结构。 lpCompletionRoutine:指定一个回调函数,在异步操作完成时调用。
/ 输出数据缓冲区指针 DWORD nOutBufferSize, // 输出数据缓冲区长度 LPDWORD lpBytesReturned, // 输出数据实际长度单元长度 LPOVERLAPPED...lpOverlapped // 重叠操作结构指针 ); 设备句柄用来标识你所访问的设备。
dwReceiveDataLength, DWORD dwLocalAddressLength, DWORD dwRemoteAddressLength, LPDWORD lpdwBytesReceived, LPOVERLAPPED...lpOverlapped ); 参数1–sListenSocket, accept前绑定到本地地址的监听socket,一般由listen()得到 参数2–sAcceptSocket, 用于接受连接的socket...(详见MSDN) 参数8–lpOverlapped,标识异步操作时的重叠IO结构信息。 使用此函数时,要包含头文:Mswsock.h,同时要链接:Mswsock.lib。
ByVal lpBuffer As Long, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByVal lpOverlapped...ByVal lpBuffer As Long, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByVal lpOverlapped...As Long) As Long 'lpOverlapped As OVERLAPPED Type OVERLAPPED Internal As Long InternalHigh
指向从文件存取数据的缓冲区的指针 DWORD nNumberOfBytesToRead; //要从文件读的字节数目 LPDWORD nNumberOfBytesRead; //一个指向读字节数的指针,存放实际从文件读的字节数目 LPOVERLAPPED...lpOverLapped; /*指向一个OVERLAPPED结构体的指针,若用FILE_FLAGOVERLAPPED打开 hFile句柄文件,则它必须指向OVERLAPPED结构体,否则,赋值为NULL
一般像WriteFile、ReadFile、DeviceIoControl函数最后一个参数lpOverlapped,是一个OVERLAPPED类型的指针,如果是同步操作,需要给这个参数赋值为NULL 异步操作方式...使用异步函数必须使用带有Ex的设备操作函数,像ReadFileEx,WriteFileEx等等,Ex系列的函数相比于不带Ex的函数来说,多了最后一个参数,LPOVERLAPPED_COMPLETION_ROUTINE...FileIOCompletionRoutine( __in DWORD dwErrorCode, __in DWORD dwNumberOfBytesTransfered, __in LPOVERLAPPED...lpOverlapped ); 第一个参数是一个错误码,如果异步操作出错,那么他的错误码可以由这个参数得到,第二个参数是实际操作的字节数对于Write类型的函数来说这个就是实际读取的字节数,第三个是一个异步对象...lpOverlapped // 这个数据结构 ) { SetEvent(lpOverlapped->hEvent); printf("IO operation end!
领取专属 10元无门槛券
手把手带您无忧上云