![]() ![]() PY fromSocketImport * fromTimeImportCTimeImportThreadingImportReHOST= "'PORT= 9999Bufsiz= 1024x768ADDR=(Host,port) Tcpsersock=Socket (Af_inet,sock_stream) tcpsersock.bind (ADDR) Tcpsersock.listen (5) clients=# Clients dictionary that records the corresponding relationship between the user name and the socket of the connected client# Chatwith The correspondence between the two sides of the communication is recorded in the dictionary# messagetransform () processing the text sent after the client determines the user name# There are only four types of text:# None# Quit# To:someone# Other textdefMessagetransform (Sock,user): while True: Data=SOCK.RECV (Bufsiz)if notDataifChatwith.has_key (sock): nd (data)delChatwith]delChatwithdelClients Sock.close () Break ifData=' Quit ': nd (data)ifChatwith.has_key (sock): Data= '%s. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |