摘要: 将多字节整数类型的数据,从主机的字节顺序转化为网络字节顺序原型:#include <netinet/in.h>uint32_t htonl(uint32_t hostlong);uint16_t htons(uint16_t hostshort);uint32_t ntohl(uint32_t netlong);uint16_t ntohs(uint16_t netshort);描述:不同的计算机里对它们的多字节整数(例如:一个大于char的整数)使用不同的字节顺序。这就意味着,如果你从intel的盒子中send()一个两个字节的短整数到一个Mac中(在它们成为Intel之前),一 阅读全文
posted @ 2012-07-01 17:35 Kingdom_0 阅读(12617) 评论(0) 推荐(0) 编辑
摘要: 原来,UDP通信,比我想象中简单的多!// WindowsSocketServer.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <string>#include <Windows.h>#include <Winsock2.h>#include <fstream>#pragma comment(lib,"Ws2_32.lib")using namespace std;#define PORT 8080#d 阅读全文
posted @ 2012-07-01 16:42 Kingdom_0 阅读(529) 评论(0) 推荐(0) 编辑
摘要: 1 // WindowsSocketServer.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include <iostream> 6 #include <string> 7 #include <Windows.h> 8 #include <Winsock2.h> 9 #include <fstream> 10 #pragma comment(lib,"Ws2_32.lib") 11 12 using namespace std; 1 阅读全文
posted @ 2012-07-01 11:03 Kingdom_0 阅读(11517) 评论(0) 推荐(0) 编辑