McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 16 Socket Interface.

44
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000 Chapter 16 Socket Interface

Transcript of McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 16 Socket Interface.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Chapter 16

SocketInterface

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

CONTENTSCONTENTS• SOME DEFINITIONS• SOCKETS• BYTE ORDERING• ADDRESS TRANSFORMATION• BYTE MANIPULATION FUNCTIONS• INFORMATION ABOUT REMOTE HOST• SOCKET SYSTEM CALLS• CONNECTIONLESS ITERATIVE SERVER

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

CONTENTS (continued)CONTENTS (continued)• UDP CLIENT-SERVER PROGRAMS• CONNECTION-ORIENTED CONCURRENT SERVER• TCP CLIENT-SERVER PROGRAMS

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

SOME DEFINITIONS

16.116.1

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-1

Data types

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-2

Internet address structure

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

SOCKETS

16.216.2

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-3

Socket address

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-4

Socket structure

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-5

Socket types

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

BYTE ORDERING

16.316.3

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-6

Big-endian byte order

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-7

Little-endian byte order

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

The byte order for the TCP/IPThe byte order for the TCP/IPprotocol suite is big endian.protocol suite is big endian.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-8

Bite-order transformation

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-9

Declarations for byte-order transformation

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

ADDRESSTRANSFORMATION

16.416.4

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-10

Address transformation

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-11

Declarations for address transformation

functions

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

BYTEMANIPULATION

FUNCTIONS

16.516.5

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-12

Declarations for byte-manipulation functions

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

INFORMATIONABOUT REMOTE

HOST

16.616.6

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-13

Declaration for gethostbyname

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-14 Hostent structure

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

SOCKET SYSTEMCALLS

16.716.7

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-15

Declaration for socket function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-16

Declaration for bind function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-17

Declaration for connect function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-18

Declaration for listen function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-19

Declaration for accept function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-20

Declaration for sendto function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-21

Declaration for recvfrom function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-22

Declaration for read function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-23

Declaration for write function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-24

Declaration for close function

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

CONNECTIONLESSITERATIVE

SERVER

16.816.8

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-25

Socket interfacefor connectionless

iterative server

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

UDP CLIENT-SERVERPROGRAMS

16.916.9

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

CONNECTION-ORIENTEDCONCURRENT SERVER

16.1016.10

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-26

Socket interfacefor connection-oriented

concurrent server

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-26 (repeated), Part I

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-26 (repeated), Part II

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-27, Part I

Clientand

Server

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000

Figure 16-27, Part II