1: Network Programming (understanding)
(1) Network programming: Using Java language to realize the information transmission and resource sharing between computer data
(2) Network programming model
(3) Three elements of network programming
A:ip Address
A: Dotted decimal
B:ip the composition of the address
Classification of C:IP addresses
D:dos command
E:inetaddress
B: Port
is the identity of the application. Range: 0-65535. 0-1024 of them are not recommended for use.
C: protocol
UDP: Data packaging, limited, not connected, high efficiency, unreliable
TCP: Set up data channel, no limit, low efficiency, reliable
(3) Socket mechanism
A: Both ends of the communication should have a socket object
B: All communication is performed via IO between sockets
(4) The UDP protocol sends and receives data (mastering its own code)
Send:
Create a socket object on the UDP send side
Create data and package the data
Send data
Freeing resources
Receive:
Creating a Socket object on the UDP receive side
Create a packet to receive data
Receive data
Parsing packets
Freeing resources
(5) The TCP protocol sends and receives data (mastering its own code)
Send:
Creating a Socket object for a TCP client
Get output stream, write data
Freeing resources
Receive:
Create a TCP server-side Socket object
Listening for client connections
Get input stream, read data
Freeing resources
(6) Case:
A:udp
A: The most basic UDP protocol to send and receive data
B: Improve the sending data to keyboard input
C: A simple chat applet with multithreading improvements
B:tcp
A: The most basic TCP protocol to send and receive data
B: The server gives feedback
C: Client keyboard input Server console output
D: Client keyboard input server writes to text file
E: Client reads text file Server console output
F: Client reads text file server writes to text file
G: Upload Images
H: Multithreading improved Upload file
Re-stepping on Java Road _day26 (network programming)