应用背景
ThisistheserverandclientcodeinCforasimplechatprogramformultipleclientcommunication.
Thisrepositorycontainscodeforaverysimplechatprogramimplementedonthelinuxsystem,usingbasesystemlibrariesandtheCprogramminglanguage.Theprogramconsistsoftwomajorcomponents,thefirstbeingtheserverprogramandthesecondistheClientprogram.
关键技术
Theserverprogrammaintainsalistofclientsandalsoaqueueofclientmessages.Itusessemaphorestomakesuresynchronisationerrorsdonotoccur.
Theserverprogramacceptsoneoptionalinputargument–listen_port_number.Ifthisargumentismissed,theserverwillusethedefaultportnumber3500(definedintheprovidedheaderfilechat_server.h).Onceitstarts,itrunsforever.Toter