- 博客(4)
- 资源 (1)
- 收藏
- 关注
原创 实例验证网络字节序、主机字节序转换函数 htonl htons ntohl ntohs的用法以及需要注意的问题
htonl: 将long型主机字节序转换为网络字节序htons: 将short型主机字节序转换为网络字节序ntohl: 将long型网络字节序转换为主机字节序 ntohs: 将short型网络字节序转换为主机字节序 项目中遇到个问题,使用了htonl函数对short型网络字节序数进行转换,导致程序出错, 以为既然是很小的数字,那么short型和lon
2013-09-17 19:53:45 1902
原创 linux下简单的TCP服务端与客户端进行网络通讯的程序
服务器端:#include #include #include #include #include #include #include #include #define portnumber 3333#define MAX_CONNET_NUM 5int main(int argc, char* argv[]){ int sockfd; int
2013-09-13 17:30:31 2079
转载 地址转换函数htonl和inet_pton
uint32_t htonl(unin32_t host32bitvalue);参数是32bit的二进制数值,在转换地址时就是32位的主机字节序ip地址(经常用点分十进制)用法:servaddr.sin_addr.s_addr=htonl(127.0.0.1);servaddr.sin_addr.s_addr=htonl(INADDR_ANY); // INADDR_ANY真实值为0.
2013-09-10 17:21:29 2649
转载 c语言实现字符串字串的替换
void Substitute(char *pInput, char *pOutput, char *pSrc, char *pDst){ char *pi, *po, *p; int nSrcLen, nDstLen, nLen; // 指向输入字符串的游动指针. pi = pInput; // 指向输出字符串的游动指针. po = pOutp
2013-09-04 17:53:23 2002
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人