Content deleted Content added
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation) |
The server process goes to sleep in the wait queue; it doesn't spin wait. |
||
Line 27:
|page=1150}}</ref>
Two processes may communicate with each other if each obtains a socket. The server process ''binds'' its socket to an ''address'', opens a ''listen'' channel, and then continuously loops
|title=Unix Network Programming
|last1=Stevens
|first1=Richard W.
|last2=Fenner
|first2=Bill
|last3=Rudoff
|first3=Andrew M.
|publisher=Pearson Education
|year=2004
|isbn=81-297-0710-1
|quote=Normally, the server process is put to sleep in the call to ''accept'', waiting for a client connection to arrive and be accepted.
|page=14}}</ref> Upon ''accepting'' a client connection, the server then executes a [[read (system call)|read]] [[system call]] that will [[Blocking (computing)|block wait]]. The client ''connects'' to the server's socket via the server's ''address''. The client process then [[write (system call)|writes]] a [[String (computer science)|message]] for the server process to read. The application's [[algorithm]] may entail multiple read/write interactions. Upon completion of the algorithm, the client executes <code>exit()</code><ref name="lpi-p1169">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
Line 214 ⟶ 226:
if ( return_value == -1 ) assert( 0 );
/* Listen and
}
</syntaxhighlight>
Line 252 ⟶ 264:
==Server accept a connection==
After opening a ''listen'' channel, the server enters an infinite loop. Inside the loop is a
|title=Linux manual page for accept()
|url=https://man7.org/linux/man-pages/man2/accept.2.html}}</ref>
|