Prev Up Next
Go backward to Client-Server Model
Go up to Top
Go forward to Berkeley Socket System Calls



Berkeley Sockets

REFERENCE: [Stevens, Chapter 6].

This is a user API from BSD Unix (ca. 1982). An alternative is the Transport Layer Interface (TLI) from System V (ca. 1986), and modeled after the OSI model [Stevens, Chapter 7]. To access these libraries, you compile your program as follows:

 


Here is how the server-client would be implemented using Berkeley sockets. There are two versions, depending on whether the communication is connection-oriented or not:




CONNECTION-BASED SERVER:

A.
 socket()
B.
 bind()
C.
 listen() (cf. step b in client)
D.
 accept() (cf. step b in client)
E.
 read() (cf. step c in client)
F.
 write() (cf. step d in client)


CONNECTION-BASED CLIENT:

a.
 socket()
b.
 connect() (cf. steps C and D in server)
c.
 write() (cf. step E in server)
d.
 read() (cf. step F in server)





CONNECTIONLESS SERVER:

A.
 socket()
B.
 bind()
C.
 recvfrom() (cf. step c in client)
D.
 sendto() (cf. step d in client)


CONNECTIONLESS CLIENT:

a.
 socket()
b.
 bind()
c.
 sendto() (cf. step C in server)
d.
 recvfrom() (cf. step D in server)





Note that only the connection-based client skip the bind() step. Below we try to explain this.



Chee Yap

Prev Up Next