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
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.