You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
380 B
Python
19 lines
380 B
Python
from socket import *
|
|
from struct import *
|
|
from threading import *
|
|
s = socket(AF_INET, SOCK_STREAM)
|
|
s.bind(('', 8888))
|
|
s.listen(100)
|
|
|
|
|
|
def proc(cs):
|
|
msglen = unpack("!i", cs.recv(4))[0]
|
|
msg = cs.recv(msglen)
|
|
cs.sendall(msg.decode().upper().encode())
|
|
|
|
|
|
while True:
|
|
(cs, addr) = s.accept()
|
|
# Thread(None, proc, args=(cs, )).start()
|
|
proc(cs)
|