-1

我创建了 Windows 窗体应用程序,但我对这段代码有疑问,有人可以帮我解决这个问题吗?感谢帮助。

    void thListen(void* Args)
        {
            const char* chIp;
            long answer; 
            WSAData wsaData;
            WORD DLLVERSION;
            DLLVERSION = MAKEWORD(2,1);
            answer = WSAStartup(DLLVERSION, &wsaData); // odpowiadanie za uzywanie wersji winsocket
            SOCKADDR_IN addr; // deklarowanie obiekut 
            int addrlen = sizeof(addr);
            SOCKET sListen;
            SOCKET sConnect; 
            sConnect = socket(AF_INET, SOCK_STREAM, NULL);

            chIp = (const char*)(void*) Marshal::StringToHGlobalAnsi(textBox1->Text);

            addr.sin_addr.s_addr = inet_addr(chIp); 
            addr.sin_family = AF_INET;                     
            addr.sin_port = htons(1234);                
            sListen = socket(AF_INET,SOCK_STREAM, NULL);   
            bind(sListen, (SOCKADDR*)&addr, sizeof(addr)); 
            listen(sListen, SOMAXCONN);
            for(;;)
            {
                if(sConnect = accept(sListen, (SOCKADDR*)&addr, &addrlen)) 
                {
                    answer = send(sConnect, "Wiadomosc",10 , NULL); 
                }
            }
            _endthread();
        }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 _beginthread(this->thListen, 0, NULL);
             }
    };
}

问题出在this->thListen哪里,错误是Error 1 error C3867: 'WinSockCommunicationApplication::Form1::thListen': function call missing argument list; use '&WinSockCommunicationApplication::Form1::thListen' to create a pointer to member c:\users\bartek\documents\visual studio 2010\projects\winsockcommunicationapplication\winsockcommunicationapplication\Form1.h 139 1 WinSockCommunicationApplication (Visual Studio 2010) 我可以放在那里()我应该做什么?

4

1 回答 1

2

做它告诉你做的事情并替换

_beginthread(this->thListen, 0, NULL);

经过

_beginthread(&WinSockCommunicationApplication::Form1::thListen, 0, NULL);
于 2013-06-18T08:58:58.387 回答