WSAEventselect 错误:10038
我已经尝试解决这个问题有一段时间了,我需要帮助,因为我没有主意。我的 WSAEventselect 函数返回错误号 10038。
代码:
// Error checking....
if(netEvent.iErrorCode[FD_ACCEPT_BIT] != 0)
{
int temp1 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
// Initializing socket
if((newClient = accept(this->info->socket, NULL, NULL)) == INVALID_SOCKET)
{
int temp2 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
// This is where the error occurs
if(WSAEventSelect(newClient, &this->info->event, FD_READ|FD_CLOSE) == SOCKET_ERROR)
{
int temp3 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
this->info
是传递到线程中的结构。
typedef struct {
SOCKET socket;
int size;
bool isTcp;
WSAEVENT event;
} SINFO, *PSINFO;
I've been trying to figure this out for a while now and I need help because I'm out of ideas. My WSAEventselect function returns error number 10038.
Code:
// Error checking....
if(netEvent.iErrorCode[FD_ACCEPT_BIT] != 0)
{
int temp1 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
// Initializing socket
if((newClient = accept(this->info->socket, NULL, NULL)) == INVALID_SOCKET)
{
int temp2 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
// This is where the error occurs
if(WSAEventSelect(newClient, &this->info->event, FD_READ|FD_CLOSE) == SOCKET_ERROR)
{
int temp3 = WSAGetLastError();
emit ClientErrorSignal();
return;
}
this->info
is a struct that is passed into the thread.
typedef struct {
SOCKET socket;
int size;
bool isTcp;
WSAEVENT event;
} SINFO, *PSINFO;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据Winsock 错误参考,这是一个
WSAENOTSOCK
错误,意味着您正在尝试使用无效的套接字句柄执行某些操作。如果没有更多有关代码中发生错误的位置的信息,我认为我无法提供更多建议,但我建议检查以确保您正确创建套接字(可能是对的调用在未初始化的套接字上接受
是罪魁祸首?)According to the Winsock error reference, this is a
WSAENOTSOCK
error, meaning you're trying to do something with an invalid socket handle. Without more information about where the error is occurring in your code I don't think I can offer much more advice than that, but I'd suggest checking to ensure that you're creating the socket correctly (perhaps the call toaccept
on an uninitialized socket is the culprit?)这可能与您的问题相关,也可能无关,但您传递给
WSAEventSelect
的第二个参数是WSAEVENT*
,而该函数需要WSAEVENT< /代码>。只需直接传递句柄,而不是其地址:
This may or may not be related to your problem, but the second parameter you're passing to
WSAEventSelect
is aWSAEVENT*
, whereas the function expects aWSAEVENT
. Just pass the handle directly, not its address: