GetQueuedCompletionStatus 失败并显示 ERROR_INVALID_NETNAME。这是什么意思?我尝试在 MSDN 中查找。
第一步:使用ConnectEx连接到服务器。 ConnectEx成功,错误代码 997 (ERROR_IO_PENDING):
DWORD bytes = 0;
sockaddr_in addr = {0};
iocp_data_t * iocp = (iocp_data_t *)module->data;
addr.sin_addr.s_addr = ip;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if(!iocp->tcp_connectex(event->fd, (const sockaddr*)&addr, sizeof(sockaddr_in),
NULL, 0, NULL, &event->connect.overlap))
{
if(!ERR_RW_RETRIABLE(socket_geterror(event->fd)))
{
return false;
}
}
return true;
GetQueuedCompletionStatus在ConnectEx调用完成后返回,但错误代码为 1214 (ERROR_INVALID_NETNAME):
fd_event_t * fd_event;
iocp_data_t * iocp = (iocp_data_t *)module->data;
rc = GetQueuedCompletionStatus(iocp->iocp, &bytes, (PULONG_PTR)&fd_event,
(LPOVERLAPPED *) &event, (u_long) 1);
if(event == NULL)
{
return;
}
DWORD err = GetLastError(); // err = 1214
event = containing_record(event,event_t,overlap);
if(event->in_used)
{
if(event->event_handler != NULL)
{
event->event_handler(module,fd_event,event->type,event->user);
}
iocp_add_event(module,fd_event,event->type,event->event_handler,event->user);
}