ipv6实现udp编程示例
本文导语: 开发测试环境:WIN7SP1、VS2005 UdpServer.cpp 代码如下:#include #include #include #pragma comment(lib, "ws2_32.lib") int main(int argc, char** argv){ using namespace std; coutai_addr, res->ai_addrlen); char recvBuf[1024] = {''}; int lenRecv = 0; struct sockaddr_storage storage;...
开发测试环境:WIN7SP1、VS2005
UdpServer.cpp
#include
#include
#include
#pragma comment(lib, "ws2_32.lib")
int main(int argc, char** argv)
{
using namespace std;
coutai_addr, res->ai_addrlen);
char recvBuf[1024] = {''};
int lenRecv = 0;
struct sockaddr_storage storage;
int len = sizeof(storage);
memset(&storage, 0, len);
lenRecv = recvfrom(sk, recvBuf, 1024, 0, (struct sockaddr*)&storage, &len);
cout