windows下的tcp服务端和客户端 windows下的tcp服务端和客户端 C++的实现,用VS2015写的,现在只实现了简单套字,下一步得支持传送文件 由于Winsock2.h是比较过时的函数,还有如果想要用scanf什么的,都必须关闭SDL检查,如下图: #include <cstdio>#include <string>#include <Winsock2.h>#pragma comment(lib,"ws2_32.lib")using namespace std;void TcpServer(int port) { const int BUF_MAX = 1024; WSADATA wsaData; SOCKET sockServer, sockClient; SOCKADDR_IN addrServer, addrClient; WSAStartup(MAKEWORD(2, 2), &wsaData); addrServer.sin_addr.S_un.S_addr = htonl(INADDR_ANY)
发表于 2017-03-02 20:43:40 | 条评论 | 阅读次数:97
Copyright © 2017 - 2018 qwb's blog
blog.csustacm.com All Rights Reserved
Powered by qwb Contact me