1 Sockets
- socket很像一个文件
- 本质上,socket是一个文件描述符指向网络设备而不是一个硬盘上的文件
int socket(int domain, int type, int protocol);- domain is the addressing domain of socket
- HTTP traffic is over TCP, so that would be SOCK_STREAM. If we wanted to open a UDP socket, the keyword would be SOCK_DGRAM
- protocol is additional information about the protocol of the socket, but we will not need to use this option, so we’ll set it to 0.
- 成功返回文件描述符,失败返回-1.
2 Addressing
2.1 Glossary of Structures and Functions
3 Storing an IP address in struct in_addr
参考:
https://www.usna.edu/Users/cs/aviv/classes/ic221/s16/lec/26/lec.html#coderef-bad_ref
本文深入解析了Socket编程的基础概念,包括socket函数的使用,其参数domain、type和protocol的意义,以及如何通过socket创建文件描述符进行网络通信。同时,介绍了如何在struct in_addr中存储IP地址。

40

被折叠的 条评论
为什么被折叠?



