Server software design Examples Chuan-Ming LIu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN CSIE NTUT Taiwan
1 CSIE, NTUT, Taiwan Server Software Design Examples Chuan-Ming Liu Computer Science and Information Engineering Spring 2004, NTUT TAIWAN
●● Examples o Iterative, Connectionless Server (UDP) o Iterative. Connected-Oriented server (TCP) o Concurrent Connection-Oriented Server(tCp) SIE NTUT. Taiwan
2 CSIE, NTUT, Taiwan Examples Iterative, Connectionless Server (UDP) Iterative, Connected-Oriented Server (TCP) Concurrent, Connection-Oriented Server (TCP)
Iterative Connectionless Server (UDP)
Iterative, Connectionless Server (UDP)
●。 Creating Passive Socket o To hide the allocation of socket use o passiveudP(passiveUDP C passiverCP(passivercPC two high-level procedures o Both procedures call passivesocko to perform socket allocation passivesock.C 4 SIE NTUT. Taiwan
4 CSIE, NTUT, Taiwan Creating Passive Socket To hide the allocation of socket, use ⚫ passiveUDP (passiveUDP.c) ⚫ passiveTCP (passiveTCP.c) two high-level procedures Both procedures call passivesock() to perform socket allocation – passivesock.c
●●● Port Privilege o To use well-known services(lower port number), the server process needs special privilege o lwo servers on a given computer can not use the same port number at the same time o How to overcome the port privilege? ● Using portbase 5 SIE NTUT. Taiwan
5 CSIE, NTUT, Taiwan Port Privilege To use well-known services (lower port number), the server process needs special privilege Two servers on a given computer can not use the same port number at the same time How to overcome the port privilege? ⚫ Using portbase
●。 Portbase o Programmer does not need to modify all references to port numbers- safety o Solves the problem in general way generality o Solving the possible port conflicts-no conflicts 6 SIE, NTUT, Taiwan
6 CSIE, NTUT, Taiwan Portbase Programmer does not need to modify all references to port numbers – safety Solves the problem in general way – generality Solving the possible port conflicts – no conflicts
●●。 Process structure server AP Socket at well-known port+OS used for all communication SIE, NTUT, Taiwa
7 CSIE, NTUT, Taiwan Process Structure server OS AP Socket at well-known port used for all communication
●。 Example o The uDPtimed. c example SIE, NTUT, Taiwa
8 CSIE, NTUT, Taiwan Example The UDPtimed.c example
Iterative Connection Oriented Server (UDP)
Iterative, ConnectionOriented Server (UDP)
●。 Creating Passive Socket o Use passivercp ( to allocate a stream socket and bind it to the well- known port o Two arguments in passiveTCP ● Name of service o Size of the queue for requests 10 SIE NTUT. Taiwan
10 CSIE, NTUT, Taiwan Creating Passive Socket Use passiveTCP() to allocate a stream socket and bind it to the wellknown port Two arguments in passiveTCP: ⚫ Name of service ⚫ Size of the queue for requests