linux:socket编程
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版 | |||
| linux:socket编程 [2026/10/13 22:10] – 外部编辑 127.0.0.1 | linux:socket编程 [2026/10/13 22:51] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 15: | 行 15: | ||
| #### - recv,read | #### - recv,read | ||
| - | < | + | |
| + | ``` | ||
| Returns the number of bytes actually recieved (which might be less than you requested in the | Returns the number of bytes actually recieved (which might be less than you requested in the | ||
| len paramter), or -1 on error (and errno will be set accordingly.) | len paramter), or -1 on error (and errno will be set accordingly.) | ||
| If the remote side has closed the connection, recv() will return 0. This is the normal method | If the remote side has closed the connection, recv() will return 0. This is the normal method | ||
| for determining if the remote side has closed the connection. | for determining if the remote side has closed the connection. | ||
| - | </ | + | ``` |
| + | |||
| ### - function | ### - function | ||
| - | < | + | |
| + | ``` | ||
| 1. Socket creation: | 1. Socket creation: | ||
| int sockfd = socket(domain, | int sockfd = socket(domain, | ||
| 行 192: | 行 195: | ||
| Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. | Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. | ||
| + | ``` | ||
| - | |||
| - | </ | ||
| 行 203: | 行 205: | ||
| ### - 服务端代码 | ### - 服务端代码 | ||
| - | < | + | |
| + | ```c | ||
| #include < | #include < | ||
| 行 281: | 行 284: | ||
| return 0; | return 0; | ||
| } | } | ||
| + | ``` | ||
| - | </ | ||
| ### - 客户端代码 | ### - 客户端代码 | ||
| - | < | + | |
| + | ```c | ||
| #include < | #include < | ||
| #include < | #include < | ||
| 行 335: | 行 339: | ||
| return 0; | return 0; | ||
| } | } | ||
| + | ``` | ||
| - | </ | ||
linux/socket编程.1791900622.txt.gz · 最后更改: 由 127.0.0.1
