Post on 09-Sep-2018
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Chapter 16
SocketInterface
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
CONTENTS• SOME DEFINITIONS• SOCKETS• BYTE ORDERING• ADDRESS TRANSFORMATION• BYTE MANIPULATION FUNCTIONS• INFORMATION ABOUT REMOTE HOST• SOCKET SYSTEM CALLS• CONNECTIONLESS ITERATIVE SERVER
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
CONTENTS (continued)• UDP CLIENT-SERVER PROGRAMS• CONNECTION-ORIENTED CONCURRENT
SERVER• TCP CLIENT-SERVER PROGRAMS
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
SOME DEFINITIONS
16.1
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-1
Data types
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-2
Internet address structure
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
SOCKETS
16.2
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-3
Socket address
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-4
Socket structure
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-5
Socket types
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
BYTE ORDERING
16.3
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-6
Big-endian byte order
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-7
Little-endian byte order
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
The byte order for the TCP/IPprotocol suite is big endian.
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-8
Bite-order transformation
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-9
Declarations for byte-order transformation
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
ADDRESSTRANSFORMATION
16.4
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-10
Address transformation
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-11
Declarations for address
transformation functions
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
BYTEMANIPULATION
FUNCTIONS
16.5
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-12
Declarations for byte-manipulation functions
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
INFORMATIONABOUT REMOTE
HOST
16.6
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-13
Declaration for gethostbyname
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-14 Hostent structure
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
SOCKET SYSTEMCALLS
16.7
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-15
Declaration for socket function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-16
Declaration for bind function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-17
Declaration for connect function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-18
Declaration for listen function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-19
Declaration for accept function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-20
Declaration for sendto function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-21
Declaration for recvfrom function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-22
Declaration for read function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-23
Declaration for write function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-24
Declaration for close function
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
CONNECTIONLESSITERATIVESERVER
16.8
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-25
Socket interfacefor connectionless
iterative server
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
UDP CLIENT-SERVERPROGRAMS
16.9
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
CONNECTION-ORIENTEDCONCURRENT SERVER
16.10
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-26
Socket interfacefor connection-oriented
concurrent server
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-26 (repeated), Part I
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-26 (repeated), Part II
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-27, Part IClientand
Server
M�G����H��� ©T�� M�G����H��� C��������� I���� 2000
Figure 16-27, Part II