Download presentation
Presentation is loading. Please wait.
Published byMarvin Gabriel Mills Modified over 9 years ago
1
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 16 Socket Interface
2
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl2 2 CONTENTS SOME DEFINITIONS SOCKETS BYTE ORDERING ADDRESS TRANSFORMATION BYTE MANIPULATION FUNCTIONS INFORMATION ABOUT REMOTE HOST SOCKET SYSTEM CALLS CONNECTIONLESS ITERATIVE SERVER
3
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl3 3 CONTENTS (continued) UDP CLIENT-SERVER PROGRAMS CONNECTION-ORIENTED CONCURRENT SERVER TCP CLIENT-SERVER PROGRAMS
4
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl4 4 SOME DEFINITIONS 16.1
5
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl5 5 Figure 16-1 Data types
6
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl6 6 Figure 16-2 Internet address structure
7
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl7 7 SOCKETS 16.2
8
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl8 8 Figure 16-3 Socket address
9
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl9 9 Figure 16-4 Socket structure
10
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl10 10 Figure 16-5 Socket types
11
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl11 11 BYTE ORDERING 16.3
12
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl12 12 Figure 16-6 Big-endian byte order
13
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl13 13 Figure 16-7 Little-endian byte order
14
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl14 14 The byte order for the TCP/IP protocol suite is big endian.
15
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl15 15 Figure 16-8 Byte-order transformation
16
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl16 16 Figure 16-9 Declarations for byte-order transformation
17
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl17 17 ADDRESS TRANSFORMATION 16.4
18
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl18 18 Figure 16-10 Address transformation
19
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl19 19 Figure 16-11 Declarations for address transformation functions
20
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl20 20 BYTE MANIPULATION FUNCTIONS 16.5
21
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl21 21 Figure 16-12 Declarations for byte-manipulation functions
22
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl22 22 INFORMATION ABOUT REMOTE HOST 16.6
23
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl23 23 Figure 16-14 Hostent structure
24
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl24 24 SOCKET SYSTEM CALLS 16.7
25
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl25 25 Figure 16-15 Declaration for socket function Create a blank socket.
26
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl26 26 Figure 16-16 Declaration for bind function Server Application binds a socket to a given socket address.
27
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl27 27 Figure 16-17 Declaration for connect function Client Application actively opens a connection with a remote server socket
28
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl28 28 Figure 16-18 Declaration for listen function Server Application is ready to receive connection requests
29
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl29 29 Figure 16-19 Declaration for accept function Server Application accepts the next connection request. A new “child” socket is created and initialized by the Operating System. Its socket descriptor is the “return value” If no requests pending, sleep.
30
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl30 30 Figure 16-20 Declaration for sendto function Application sends UDP data to a remote socket
31
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl31 31 Figure 16-21 Declaration for recvfrom function Get the next message arriving at a socket, as well as the socket address of the sender. Usually used by a UDP process
32
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl32 32 Figure 16-22 Declaration for read function Read the next message arriving at a specific Stream (i.e. TCP) socket. Assumes that the connection has already been opened.
33
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl33 33 Figure 16-23 Declaration for write function Send a message to a specific Stream (i.e. TCP) socket. Assumes that the connection has already been opened.
34
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl34 34 Figure 16-24 Declaration for close function Terminate the TCP connection
35
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl35 35 CONNECTIONLESS ITERATIVE SERVER 16.8
36
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl36 36 Socket interface for connectionless iterative server
37
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl37 37 UDP CLIENT-SERVER PROGRAMS 16.9
38
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl38 38 CONNECTION-ORIENTED CONCURRENT SERVER 16.10
39
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl39 39 Figure 16-26 Socket interface for connection-oriented concurrent server
40
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl40 40 Figure 16-26 (repeated), Part I
41
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl41 41 Figure 16-26 (repeated), Part II
42
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl42 42 Figure 16-27, Part I Client and Server
43
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl43 43 Figure 16-27, Part II
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.