winsock客户端

2021-05-07 21:26

阅读:353

标签:return   com   mil   version   turn   rtu   close   nec   stream   

#include "winsock2.h"
#pragma comment(lib,"WS2_32.lib")

WSADATA wsaData;
WORD sockVersion = MAKEWORD(2,0);
WSAStartup(sockVersion,&wsaData);
SOCKET s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(s==INVALID_SOCKET)
{
          return;
}
sockaddr_in servAddr;
servAddr.sin_family=AF_INET;
servAddr.sin_port=htons(PORT);   
servAddr.sin_addr.S_un.S_addr=inet_addr(IP);
if(connect(s,(sockaddr*)&servAddr,sizeof(servAddr))==-1)
{
          return;
}
//send
//recv
closesocket(s);

  

winsock客户端

标签:return   com   mil   version   turn   rtu   close   nec   stream   

原文地址:http://www.cnblogs.com/hatsusakana/p/7639586.html


评论


亲,登录后才可以留言!