
TCP
文章平均质量分 76
笑峰
if天堂go paradiseelse go inferno
展开
-
简单的web服务器实现
#include #include #include #include #include #include #include #include #include #define MAXLINE 2048 #define PORT 12345 #define WebRoot "/home/xrf/www" /* 字符串s1 是否以字符串 s2结原创 2013-03-12 11:04:42 · 563 阅读 · 0 评论 -
去掉输入参数的tcping
/* tcping does a nonblocking connect to test if a port is reachable. * Its exit codes are: * -1 an error occured * 0 port is open * 1 port is closed * 2 user timeout *原创 2013-03-14 22:03:20 · 910 阅读 · 0 评论 -
IP和TCP包头校验和的计算方法
校验和的算法:将数据以字为单位累加到一个双字中,如果数据长度为奇数,最后一个字节要先变成字,然后在加到原来的双字中,最后得到的结果是一个双字,最后将这个双字的高16位和低16位反复相加,直到高16位为0,从而就获得一个16位的值,再将这个16位的值取反就得到校验和的值了。在接收端接收到IP数据包后,要对IP头进行检查看是否有误,所用的算法与上面一致,不同的是最终的结果要为0。转载 2013-05-29 10:11:40 · 838 阅读 · 1 评论