WSAEventselect 错误:10038

发布于 2024-10-17 02:09:33 字数 998 浏览 2 评论 0原文

我已经尝试解决这个问题有一段时间了,我需要帮助,因为我没有主意。我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

童话里做英雄 2024-10-24 02:09:33

根据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 to accept on an uninitialized socket is the culprit?)

岁月苍老的讽刺 2024-10-24 02:09:33

这可能与您的问题相关,也可能无关,但您传递给 WSAEventSelect 的第二个参数是 WSAEVENT*,而该函数需要 WSAEVENT< /代码>。只需直接传递句柄,而不是其地址:

WSAEventSelect(..., info->event, ...);

This may or may not be related to your problem, but the second parameter you're passing to WSAEventSelect is a WSAEVENT*, whereas the function expects a WSAEVENT. Just pass the handle directly, not its address:

WSAEventSelect(..., info->event, ...);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文