while ( 1) {
if ÓÐÐÂÁ¬½Ó then ½¨Á¢²¢¼Ç¼¸ÃÐÂÁ¬½Ó;
for ( ËùÓеÄÓÐЧÁ¬½Ó)
begin
if ¸ÃÁ¬½ÓÖÐÓÐ×Ö·û¿É¶Á then
begin
¶ÁÈë×Ö·û´®£»
for ( ËùÓÐÆäËûµÄÓÐЧÁ¬½Ó)
begin
½«¸Ã×Ö·û´®·¢Ë͸ø¸ÃÁ¬½Ó;
end;
end;
end;
end.
while ( ²»ÏëÍ˳ö)
begin
if ( Óë server µÄÁ¬½ÓÓÐ×Ö·û¿É¶Á)
begin
´Ó¸ÃÁ¬½Ó¶ÁÈë, ²¢Êä³öµ½±ê×¼Êä³öÉÏÈ¥.
End;
if ( ±ê×¼ÊäÈë¿É¶Á)
Begin
´Ó±ê×¼ÊäÈë¶ÁÈë, ²¢Êä³öµ½Óë server µÄÁ¬½ÓÖÐÈ¥.
End;
End.
ÉÏÃæµÄ¶Áд·Ö±ðµ÷ÓÃÕâÑùÁ½¸öº¯Êý:
read( userfd[i], line, MAX_LINE);
// userfd[i] ÊÇÖ¸µÚ i ¸ö client Á¬½ÓµÄÎļþÃèÊö·û.
// line ÊÇÖ¸¶Á³öµÄ×Ö·û´æ·ÅµÄλÖÃ.
// MAX_LINE ÊÇÒ»´Î×î¶à¶Á³öµÄ×Ö·ûÊý.
// ·µ»ØÖµÊÇʵ¼Ê¶Á³öµÄ×Ö·ûÊý.