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.

25 lines
570 B
Python

#this script is from the server side, to listen.
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('localhost', 3333))
s.listen(5)
flag = 0
while True:
connect, addr = s.accept()
print("Connection Address:" + str(addr))
str_return = "I am listening. Waiting for command."
connect.sendto(bytes(str_return, 'utf-8'), addr)
str_recv, temp = connect.recvfrom(1024)
print(str_recv)
str_return = "I got your command, it is " + str(str_recv)
connect.sendto(bytes(str_return, 'utf-8'), addr)
connect.close()