Java Network Programming: What is Socket Programming?

The so-called socket commonly also referred to as "socket" is used to describe IP address and port, the handle is a communication chain. Applications typically issues a request to the network through a "socket" network request or response.

We develop web applications located in the application layer, TCP and UDP transport layer protocols belong to, how to use the services of the transport layer in the application layer it? Between the application layer and the transport layer, the separation is carried out using the socket.

Socket as the transport layer to the application layer to open a small port, the application sends data to the remote through this small opening, or receiving remote data sent; and within this small opening, i.e. the data after the port into or data from prior to this out of the mouth, you do not know or need to know, does not care how it is transmitted, which is a network other levels of work.

Socket API is actually supplied transport layer application layer. The transport layer process to process Q provides the logical channel based on the network layer, and application layer process is a process using a transport layer communication to another host. Socket is a bridge between the application layer and the transport layer

Use Socket programming can develop client and server applications that can communicate on the local network, but also through Internet communications on a global scale.

wuliao

wuliao

Life Case 1: If you want to write e-mails sent to distant friends, how to write a letter, the letter pack, belongs to the application layer. How to write letters, how completely packed's up to us; and when we dropped the letter into the mailbox, the mailbox is opening a socket, after entering the socket, is the transport layer, network layer, etc. (post office, road or route traffic control etc.) other levels of work. We never do not care how the letter was sent to Beijing from Xi'an, we only know that written into the mailbox on OK.

Life Case 2: Socket can be likened to a port, as long as the application data to the Socket, even completed sending data, the details done by Socket, without knowing the details. Similarly, for the recipient, the application must create a pier, waiting for the arrival of data, and retrieve data.

Guess you like

Origin www.cnblogs.com/Yanss/p/11712356.html