Network programming assignment I. fill in the blanks

< p align = "center" > network programming

2、 Multiple choice questions

Although the name of TCP / IP is TCP, its transport layer includes two protocols: TCP and UDP

TCP is the abbreviation of tranfer control protocol. It is a connection oriented protocol to ensure reliable transmission.

UDP is the abbreviation of userdatagram protocol. It is a connectionless protocol. Each datagram is an independent message

  TCP:

Advantages: 1. Connection oriented transmission; 2. Stable and reliable data transmission; 3. End to end communication; 4. Full duplex mode; 5. Transmission in bytes

Disadvantages: the transmission speed is not fast enough

  UDP:

Advantages: 1. Fast transmission speed; 2. High efficiency;

Disadvantages: packets may be lost

Tip: explain the programming steps of server and client respectively.

In socket program development, the server uses ServerSocket to wait for the connection of the client. For Java network programs, each client is represented by a socket object.

Socket communication process: (1) create a socket (client) ServerSocket (server) (2) the client / server opens and connects the socket input / output stream (3) perform read / write operations according to certain rules (4) close socket related

Tip: explain the programming steps of server and client respectively.

Implementation process: server side (server): 1. Construct the datagram socket instance and specify the local port. 2. Receive the datagram packet through the receive method of the datagram socket instance. The datagram packet contains the communication content in the middle. 3. Receive and send the datagram packet through the send and receive methods of the datagram socket. Client (client): 1. construct DatagramSocket instance. 2. send DatagramPacket message through send and receive method of DatagramSocket instance. After 3., close method calling DatagramSocket is closed.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>