IOS learning and ios learning routes
Socket is an intermediate software abstraction layer for communications between the application layer and the TCP/IP protocol. It is a group of interfaces.
TCP: connection-oriented, reliable transmission (ensuring data correctness and Data Order), used to transmit a large amount of data (stream mode), slow speed, and costly connection establishment (time, system Resources ). UDP: for non-connection, unreliable transmission, for transmitting a small amount of data (packet mode), fast
There are two common Socket types:1. stream Socket (SOCK_STREAM) connection-oriented Socket for connection-oriented TCP Service applications 2. datagram-type connectionless Socket, corresponding to connectionless UDP Service applications Socket call library functions mainly include: 1. create Socket (af, type, protocol) 2. establish the connection between the address and socket bind (socked, local addr, addrlen) 3. the server listens to the client request listen (Sockid, quenlen) 4. establish a connection between the server and client (for TCP connections). The client requests to Connect (socked, destaddr, addrlen. the server waits for receiving the Client Connection Request newsockid = accept (Socked, Clientaddr, paddrlen) 6 from the Socket numbered Sockid. send/receive data connection-oriented: send (socked, buff, bufflen) recv () 7. connection-free: sendto (socked, buff ,... , Addrlen) recvfrom () 8. Release socket close (sockid)