socketchannel,26 Socket Addressing and Client Socket Programming

 2023-10-05 阅读 31 评论 0

摘要:1 Sockets socket很像一個文件本質上,socket是一個文件描述符指向網絡設備而不是一個硬盤上的文件int socket(int domain, int type, int protocol); domain is the addressing domain of socketHTTP traffic is over TCP, so that would be SOCK_STREAM. If we wanted to ope

1 Sockets

  1. socket很像一個文件
  2. 本質上,socket是一個文件描述符指向網絡設備而不是一個硬盤上的文件
  3. int socket(int domain, int type, int protocol);
    1. domain is the addressing domain of socket
    2. 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
    3. 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.
    4. 成功返回文件描述符,失敗返回-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

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/116015.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息