Understanding Sockets and TCP for Client-Server Communication


Learn about different types of sockets, client-server architecture, and TCP protocol for reliable data transmission over the network.
- Uploaded on | 0 Views
-
jared
About Understanding Sockets and TCP for Client-Server Communication
PowerPoint presentation about 'Understanding Sockets and TCP for Client-Server Communication'. This presentation describes the topic on Learn about different types of sockets, client-server architecture, and TCP protocol for reliable data transmission over the network.. The key topics included in this slideshow are . Download this presentation absolutely free.
Presentation Transcript
1. 11.2 Sockets
2. Client - Server - (client - server). - . , , - . - , , , .
3. Client - Server , , , (.. , , mail ). , server . , , . , .
4. Sockets Socket , , . , . socket, file system. sockets: TCP - UDP
5. TCP Sockets To TCP (Transmission Control Protocol) socket (connection- oriented service). . H TCP socket (handshake packets) UDP datagrams. TCP sockets : .
6. UDP Sockets To UDP (Unreliable Datagram Protocol ) socket ( connectionless service ). . . , . .
7. Java.net package
8. Client - Server TCP O ( EchoClient ) socket() - server getInputStream() - socket / getOutputStream() read() write() - socket stream / close() - socket .
9. Client - Server TCP O (EchoServer ) ServerSocket() - listening socket accept() - new Thread - thread getInputStream() - socket accept ( Socket) / getOutputStream()
10. Client - Server TCP O (EchoServer ) - read() write() - socket - stream / close() - socket ( listening )
11. Datagrams (1) UDP Datagrams peer-to-peer, . . - / . datagrams, ( packets )
12. TimeClient/TimeServer (1) O TimeClient, host, . TimeServer , host. server 8505 , . : DatagramSocket, UDP datagrams DatagramPacket, .
13. TimeClient (1) host TimeServer. java TimeClient 127.0.0.1 To InetAddress, getByName(String), InetAddress : InetAddresshostAddress = InetAddress.getByName(args[0]);
14. TimeClient (2) datagram socket, . : DatagramSocket serversoc = new DatagramSocket(); , port , datagram socket. , datagram socket streams /, / , .
15. TimeClient (3) . DatagramPacket. DatagramPacket packet; byte[] message = new byte[256]; packet = new DatagramPacket(message, 256, hostaddress, port); , , send(DatagramPacket) datagram socket : serversoc.send(packet); receive(DatagramPacket) datagram socket. Serversoc.receive(packet);
16. TimeClient (4) receive() , datagram port datagram socket. M getData() DatagramPacket, bytes , String . getInetAddress() getPort() , . , close() DatagramSocket().
17. TimeServer(1) (max 8KBytes). datagram socket, . O DatagramSocket port 8505, , . , thread. receive(DatagramPacket) datagram socket. s.receive(packet);
18. TimeServer(2) getInetAddress() getPort() , . : String String port . , , send(DatagramPacket) datagram socket