In-depth analysis of MapReduce Architecture Design and Implementation Principles-Reading Notes (7) hadoop Network

Source: Internet
Author: User
Java Network programming is based on the TCPIP Protocol and is committed to implementing the application layer. The transport layer provides the Socket interface to the application layer, which encapsulates the data transmission details of the lower layer. The Application Layer Program establishes a connection with the remote host through the Socket for data transmission. TCPTCP is short for TranferControlProtocol and is a connection-oriented

Java Network programming is based on the TCP/IP protocol and is committed to implementing the application layer. The transport layer provides the Socket interface to the application layer, which encapsulates the data transmission details of the lower layer. The Application Layer Program establishes a connection with the remote host through the Socket for data transmission. TCP is short for Tranfer Control Protocol and is a connection-oriented

Java Network programming is based on the TCP/IP protocol and is committed to implementing the application layer. The transport layer provides the Socket interface to the application layer, which encapsulates the data transmission details of the lower layer. The Application Layer Program establishes a connection with the remote host through the Socket for data transmission.

TCP

TCP is short for Tranfer Control Protocol. It is a connection-oriented Protocol that ensures reliable transmission. It is transmitted over TCP to obtain a sequential error-free data stream. The sender and receiver must establish a connection between two pairs of sockets to facilitate communication based on the TCP protocol. When a socket (usually a server socket) is waiting to establish a connection, another socket can require a connection. Once the two sockets are connected, they can perform bidirectional data transmission, and both parties can send or receive data.

UDP

UDP is short for User datasync Protocol. It is a connectionless Protocol. Each Datagram is an independent information, including the complete source address or destination address, it is transmitted to the destination in any possible path on the network. Therefore, the correctness of the arrival time, arrival time, and content cannot be guaranteed.

Compare UDP

1. Complete address information is provided in each datagram, so there is no need to establish a connection between the sender and the receiver.
2. UDP data transmission has a size limit. Each transmitted datagram must be within 64 KB.
3. UDP is an unreliable protocol. The data packets sent by the sender do not necessarily arrive at the receiver in the same order.

TCP

1. connection-oriented protocol. A connection must be established before data transmission between sockets. Therefore, the connection time is required in TCP.
2. TCP transmission data size limit. Once the connection is established, the sockets of both parties can transmit big data in a unified format.
3. TCP is a reliable protocol that ensures that the receiver fully and correctly obtains all data sent by the sender.

Socket

Java.net. Socket and java. netServerSocket are built on the TCP protocol.
Java.net. DatagramSocket is built on the UDP protocol.

Server process

  1. // Create a server process
  2. ServerSocket serverSocket = new ServerSocket (port );
  3. // Listen for requests from the client
  4. Soc = serverSocket. accept ();
  5. // Construct a data input stream to receive data
  6. DataInputStream in = new DataInputStream (soc. getInputStream ());
  7. // Construct a data output stream to send data
  8. DataOutputStream out = new DataOutputStream (soc. getOutputStream ());
  9. // Disconnect
  10. Soc. close ()

Client Process

  1. // Create a client Socket
  2. Socket soc = new Socket (serverHost, port );
  3. // Construct a data input stream to receive data
  4. DataInputStream in = new DataInputStream (soc. getInputStream ());
  5. // Construct a data output stream to send data
  6. DataOutputStream out = new DataOutputStream (soc. getOutputStream ());
  7. // Disconnect
  8. Soc. close ()

Original article address: in-depth analysis of MapReduce Architecture Design and Implementation Principles-Reading Notes (7) hadoop network programming, thanks to the original author for sharing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.