You are on page 1of 44

Chapter 16

Socket Interface
McGraw-Hill The McGraw-Hill Companies, Inc., 2000

CONTENTS
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)
UDP CLIENT-SERVER PROGRAMS CONNECTION-ORIENTED CONCURRENT SERVER TCP CLIENT-SERVER PROGRAMS

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

16.1 SOME DEFINITIONS

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

16.2 SOCKETS

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

16.3 BYTE ORDERING

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/IP 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

16.4 ADDRESS TRANSFORMATION

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

16.5
BYTE MANIPULATION FUNCTIONS

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

Figure 16-12

Declarations for byte-manipulation functions

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

16.6
INFORMATION ABOUT REMOTE HOST

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

16.7 SOCKET SYSTEM CALLS

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

16.8
CONNECTIONLESS ITERATIVE SERVER

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

Figure 16-25

Socket interface for connectionless iterative server

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

16.9 UDP CLIENT-SERVER PROGRAMS

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

16.10 CONNECTION-ORIENTED CONCURRENT SERVER

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

Figure 16-26

Socket interface for 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

Client and Server

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

Figure 16-27, Part II

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

You might also like