Professional Documents
Culture Documents
• Client-Server Transactions
• Programmer’s View of Internet
• Internet Connections
• Clients
• Using Ports to Identify Services
• Servers
Client-Server Transactions
2
12
Client-Server Transactions
Client Server
process process Resource
3
12
Programmer’s View of Internet
4
12
Internet Connections
point-to-point Full-duplex
(2-way
Communication)
Connections
Reliable
5
12
Internet Connections
Server socket
Client socket address
address
128.2.194.242:51213
134.173.42.2:80
Server
Client
(port 80)
Web
ftp telnet ssh
browsers
7
12
Clients
8
12
Clients
9
12
Using Ports to Identify Services
10
12
Servers
11
12
Servers
Each server waits for requests to arrive on well-known
port associated with that particular service
2
15
Sockets: Communication Endpoints
3
15
Sockets: Communication Endpoints
4
15
Overview of Sockets Interface
5
15
Connection-Oriented Sockets
6
15
Connection-Oriented Sockets
7
15
Socket process for connection
oriented clients and servers
8
15
socket() Module Function
To create a socket, you must use the socket.socket()
function, which has the general syntax:
9
15
socket() Module Function
The protocol is usually left out, defaulting to 0.
10
15
Socket Object (Built-In) Methods
Server Socket Methods
11
15
Socket Object (Built-In) Methods
Client Socket Methods
12
15
Socket Object (Built-In) Methods
General Socket Methods
13
15
Socket Object (Built-In) Methods
General Socket Methods
s.getpeername ()
Remote address connected to socket (TCP)
s.getsockname()
Address of current socket
s.getsockopt()
Return value of given socket option
s.setsockopt()
Set value for given socket option
14
15
Socket Object (Built-In) Methods
General Socket Methods
s.shutdown ()
Shut down the connection
s.close()
Close socket
s.detach()
Close socket without closing file descriptor,
return the latter
s.ioctl()
Control the mode of a socket
15 (Windows only)
15
03 Connection Oriented Sockets