Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- with socket(AF_INET, SOCK_STREAM) as s:
- s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
- address = ('', 7788)
- s.bind(address)
- s.listen()
- while True:
- print('WAITING FOR CONNECTIONS...')
- newConn, newAddr = s.accept()
- with newConn:
- print('%s CLIENT ACCEPTED...' % newAddr[0])
- p = Process(target=recv, args=(newConn, newAddr))
- p.start()
- def recv(newConn, newAddr):
- while True:
- recvData = newConn.recv(1024)
- if len(recvData) > 0:
- dataprocessing(recvData)
- else:
- print('%s CLIENT DISCONNECTED' % newAddr[0])
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement