Socket network programming, socket
Socket network programming network communication three elements:
- IP Address [host name]
- Identifier of the device in the Network
- Local loopback address: 127.0.0.1 Host Name: localhost
- Port Number
- The logical address used to identify the process.
- Valid port: 0 ~ 65535
- 0 ~ 1024 is used or reserved by the system. Do not use port 1024 during development.
- Transmission Protocol [communication rules]
Common network protocols
Protocol |
Port |
Description |
HTTP |
80 |
Hypertext Transfer Protocol |
HTTPS |
443 |
HTTP + SSL, HTTP Security Edition |
FTP |
990 |
File Transfer |
POP3 |
110 |
Email Protocol |
SMTP |
25 |
Simple Mail Transfer Protocol |
Telnet |
23 |
Remote Terminal Protocol |
Network Reference Model
TCP & UDPUDP (User datasync Protocol User Datagram)
- Send the message without confirming whether the recipient has received the message.
- Encapsulate data and source and target data into data packets without establishing a connection
- The size of each datagram is limited64 kWithin
- Because no connection is required, the Protocol is not reliable,Fast transmission speed
TCP (Transmission Control Protocol)
- Establish a connection to form a data transmission channel
- Transfer big data in the connection (Unlimited data size),
- The three-way handshake is a reliable protocol for Secure delivery.
- Connection is required, so the efficiency is relatively low.
Explanation on Socket Baidu encyclopedia
- The original meaning of Socket is "hole" or "Socket ". As the process Communication Mechanism of bsd unix, take the latter meaning. It is also called "socket". It is used to describe the IP address and port and is a communication chain handle. Hosts on the Internet generally run multiple service software and provide several services at the same time. Each service opens a Socket and binds it to a port. Different ports correspond to different services. Socket is like a porous Socket, just as it was originally intended. A host is like a room with various sockets. Each socket has a serial number. Some sockets provide 220 v ac, some provide 110 v ac, and some provide cable TV programs. The customer software inserts the plug into a socket with different numbers to obtain different services.
Functions of Socket
- Socket is a mechanism provided for network services.
- In Unix, the network is both Socket and not limited to TCP/UDP.
- Socket can be used for custom protocols
- Both ends of the communication are Socket
- Network Communication is actually the communication between sockets.
- Data is transmitted through IO between two sockets
Socket Communication
Scoket Development