[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
To run this script, pass no arguments to talk to a server listening on port 50007 on the local machine; pass a real machine name ...
a connection is accepted, to simulate a long-running task (this is from file echo-server- sleep.py in the examples package if yo ...
Client received: b'Echo=>Hello network world' Client received: b'Echo=>Hello network world' Client received: b'Echo=>He ...
modules do the same for other standard ports (e.g., NNTP, Telnet, and so on). We’ll meet some of these client-side protocol modu ...
request prevents the server from returning to the code that checks for new clients in a timely manner, it won’t be able to keep ...
reply = 'Echo=>%s at %s' % (data, now()) connection.send(reply.encode()) connection.close() os._exit(0) def dispatcher(): # l ...
[server window (SSH or Telnet)] [...]$ uname -p -o i686 GNU/Linux [...]$ python fork-server.py Server connected by ('72.236.109. ...
encoding instead of byte string concatenation, the client’s message is shown as byte string explicitly here. Other run modes: Lo ...
C:\...\Internet\Sockets> python echo-client.py learning-python.com Blue, no yellow! Client received: b"Echo=>b'Blue,' at S ...
activeChildren, of the process IDs of all child processes it spawns. Whenever a new incoming client request is received, the ser ...
[...]$ ps -f UID PID PPID C STIME TTY TIME CMD 5693094 20515 30778 0 04:43 pts/0 00:00:00 python fork-server.py 5693094 21646 20 ...
""" import sys, signal, time def now(): return time.asctime() def onSignal(signum, stackframe): # Python signal handler print('G ...
5693094 11592 30778 0 05:00 pts/0 00:00:00 python signal-demo.py 17 5693094 11728 30778 0 05:01 pts/0 00:00:00 ps -f 5693094 307 ...
connection, address = sockobj.accept() # pass to process for service print('Server connected by', address, end=' ') print('at', ...
Server connected by ('72.236.109.185', 58833) at Sun Apr 25 08:16:34 2010 Server connected by ('72.236.109.185', 58834) at Sun A ...
while True: # wait for next connection, connection, address = sockobj.accept() # pass to process for service print('Server conne ...
socket.error: [Errno 10038] An operation was attempted on something that is not a socket Recall from Chapter 5 that on Windows m ...
If you read Chapter 5, you know that one solution to all of these dilemmas is to use threads rather than processes. Threads run ...
This dispatcher delegates each incoming client connection request to a newly spawned thread running the handleClient function. A ...
Client received: b"Echo=>b'Brian' at Sun Apr 25 12:41:52 2010" C:\...\PP4E\Internet\Sockets> python echo-client.py localho ...
«
38
39
40
41
42
43
44
45
46
47
»
Free download pdf