The fifth day of the dark horse programmer

Source: Internet
Author: User

-------
Android training and Java training. We look forward to communicating with you! ----------

  • Network Programming is actually socket-based programming, which requires several pieces of data; 1) ip address; 2) port number; 3) transmission protocol;
  • The network programming model is TCP/IP;
  • Introduce the Differences Between TCP and UDP:
  1. UDP encapsulates data and source and target data into data packets without establishing a connection.
  2. The maximum size of each UDP datagram is 64 KB.
  3. Because UDP is not connected, it is an unreliable protocol. Because there is no connection, the speed is fast.
  4. UDP is generally used in video conferencing and chat software .................
  5. TCP must establish a connection, thus forming a channel for data transmission.
  6. TCP implements a large amount of data transmission in the connection.
  7. TCP completes the connection through three handshakes, which is a reliable protocol, because the connection efficiency will be slightly lower.
  8. TCP is used to download online movies .............
  • Socket is a mechanism provided for network services.
  • Both ends of the communication have sockets. network communication is actually inter-socket communication. Data is transmitted through Io between the two sockets.
  • Datagramsocker is a class in the java.net package, which indicates the socket used to send and receive the datagram package. Always enable UDP broadcast sending on mongoramsocket. To receive broadcast packets, bind the datagramsocket to a wildcard address. In some implementations, the broadcast package can also be received when the initramsocket is bound to a more specific address.
    Example: datagramsocket S = new datagramsocket (null); S. BIND (New inetsocketaddress (8888); this is equivalent to: datagramsocket S = new datagramsocket (8888); both examples can create the datagramsocket that can receive broadcasts on UDP port 8888.


  • The procedure for establishing a UDP sending end is as follows: 1) Establish a sender end and an acceptor 3) establish a data packet 4) Call the sending and receiving method of the socket 5) disable the socket
  • The procedure for establishing a UDP acceptor is as follows: 1) define udpsocket Service 2) define a data packet because the received byte data is to be stored because more functions are available in the data packet object, different information in the byte data can be extracted. 3) the received data is saved to the predefined data through the receive method of the socket service. 4) the special function of the data packet object is used, 5) Close the resource

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.