2013-06-18 99 views
-1

我創建了Windows窗體應用程序,我有這個代碼的問題有人可以幫助我嗎?感謝幫助。函數調用缺少參數列表錯誤(C++)

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) 我可以把有()我768,16辦?

+1

我的意思是,真的。這個錯誤以簡單的英文表達出來。它不能做得更好。 – chris

回答

2

做它告訴你這樣做和替換

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

通過

_beginthread(&WinSockCommunicationApplication::Form1::thListen, 0, NULL); 
+0

謝謝身體,但我不能做到這一點,也許我不知道還有什麼,但如果我把這_beginthread(&WinSockCommunicationApplication :: Form1 :: thListen,0,NULL);在代碼中我有下一個錯誤稱爲:指針成員是無效的託管類 –

+0

http://stackoverflow.com/questions/7170269/c-thread-in-member-function – rectummelancolique

相關問題