2015年7月14日
|
阅读
- 使用
bzero而不是memset
- 使用
inet_pton而不是inet_addr
struct sockaddr, that is, a generic socket address structure. Everytime one of the socket functions requires a pointer to a socket address structure, that pointer must be cast to a pointer to a generic socket address structure.
(因为socket函数出现的时候还没有void*)struct sockaddr太长了,一般会缩写成SA
- tcp编程里关于读数据
when reading from a TCP socket, we always need to code the read in a loop and terminate the loop when either read returns 0 (i.e., the other end closed the connection) or a value less than 0 (an error).
- 协议无关性
getaddrinfo:这个函数可以写出和协议( IPv4 or IPv6) 无关的代码
没有标签