Sockets: Introduction
目录 Sockets: Introduction Overview Creating a Socket: socket() Binding a Socket to an Address: bind() Generic Socket Address Structures: struct sockaddr Stream Sockets Listening for Incoming Connections: listen() Accepting a Connection: accept() Connecting to a Peer Socket: connect() I/O on Stream Sockets Datagram Sockets Exchanging Datagrams: recvfrom() and sendto() Using connect() with Datagram Sockets Sockets: Introduction Overview fd = socket(domain, type, protocol); Communication donmains 每个socket必须存在于一个 communication domain 中,该域决定了: 标识一个socket的方法(一个socket地址的格式); 通信的范围(比如在同一个主机上不同应用之间的通信