大虾们帮我看看这段关于SOCKET的代码!!!!谢谢!!!!
代码如下:程序代码:
#include <winsock.h> #include <iostream> #pragma comment(lib, "ws2_32.lib") using namespace std; int main(void) { int iflag; WSADATA wsadata; SOCKET m_socket; iflag = WSAStartup(MAKEWORD(2, 2), &wsadata); if (iflag != 0) { cout<<"Sock opens failed!!"<<endl; return 0; } else { cout<<"Sock opens successfully!!"<<endl; return 0; } m_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (m_socket == INVALID_SOCKET) { cout<<"Error at socket() "<<GetLastError()<<endl; WSACleanup(); return 0; } return 0; }
错误信息如下:
c:\........(省略的路径): undefined reference to "WSAStartup@8"
collect 2: ld returned 1 exit status