
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of socket programming techniques used in tcp client-server architecture, focusing on i/o multiplexing. Topics include differentiating between blocking and non-blocking calls, defining structures for client-server interaction, and understanding transport services and names and addresses. The document also covers socket i/o functions such as socket(), bind(), listen(), and accept().
Typology: Exercises
1 / 40
This page cannot be seen from the preview
Don't miss anything!

































^
5
docsity.com
applicationtransportnetworkdata link
Initiates contact with server(“speaks first”)
dataphysical
-^
Typically requests service fromserver,
-^
For Web, client is implemented in
request
,^
p
browser; for e-mail, in mailreader
replyapplicationtransportnetworkdata linkh
i^
l
Provides requested service toclient
-^
e g
Web server sends
p y physical
-^
e.g., Web server sendsrequested Web page, mail serverdelivers e-mail
Some apps (e.g., audio) cantolerate some loss
Other apps (e g
file
Some apps (e.g., Internettelephony, interactivegames) require low delay to
Other apps (e.g., filetransfer, telnet) require100% reliable data transfer
g^
)^
q^
y
be “effective”
Some apps (e.g., multimedia) require minimum amount ofb^
d^
idth t
b
“ ff
ti^
”
bandwidth to be “effective”
-^
Other apps (“elastic apps”) make use of whatever bandwidth theyget
^
^
^
^
^
11
412-268-8000ext.
412-268-8000ext.
ext.
Port 80
Port 25
ext.
Port No.
Extension Central Number
Exchange
IP AddressNetwork No.
Telephone NoExchangeArea Code
Host Number
12
TCP Server
For example: web server
For example: web server ^
What does a
web server
need to do so that a
web
client
can connect to it?
Socket I/O: bind() ^
A
socket
can be bound to a
port
()
int
fd;
socket
descriptor
struct
sockaddr_in
srv;
/* used
by
bind()
/* create
the
socket
srv.sin_family
use
the
Internet
addr
family
srv.sin_port
htons
bind
socket
‘fd’
to
port
bind:
a^
client
may
connect
to
any
of
my
addresses
srv.sin_addr.s_addr
htonl
if(
bind
(fd,
(struct
sockaddr*)
&srv,
sizeof(srv))
perror("bind");
exit(1);
17
-^
Still not quite ready to communicate with a client...
-^
Still not quite ready to communicate with a client...
-^
cli.sin_addr.s_addr
contains the client’s
IP address
-^
cli.sin_port
contains the client’s
port number
20
^
21