资 源 简 介
socket 网络通信 控制台程序 测试通过
#include
#include
#pragma comment(lib, "ws2_32.lib")
void main()
{
WORD wVersionRequested;
WSADATA wsaData;//WSAata用来存储系统传回的关于WinSocket的资料。
int err;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||HIBYTE( wsaData.wVersion ) != 1 )
{
WSACleanup( );
return;
}
SOCKET sockClient=socket(AF_INET,SOCK_STREAM,0);// AF_INET ..tcp连接
//初始化连接与端口