[英]How can I send command to my Python script via application on Android phone?
i have my server.py which i wanna run on my PC我有我想在我的电脑上运行的 server.py
print ('# server.py')
import socket
host = socket.gethostname()
port = 2137
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(5)
while True:
clientsocket, addr = s.accept()
message = clientsocket.recv(1024).decode()
print('{} > {}'.format(str(addr), message))
clientsocket.close()
and my client.py which i wanna transform into an application for android phone和我的 client.py,我想将其转换为 android 手机的应用程序
print ('# client.py')
import socket
host = socket.gethostname()
port = 2137
while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
message = input('message: ')
s.send(message.encode('ascii'))
s.close()
is it possible?可能吗? to send data from my phone to my pc?
将数据从我的手机发送到我的电脑? and how could i do it?
我该怎么做?
It is definitely possible to send data from your phone to your computer.绝对可以将数据从手机发送到计算机。 But you have to take care of port forwarding (in the router configuration) to make your PC visible from outside the network.
但是您必须注意端口转发(在路由器配置中),以使您的 PC 从网络外部可见。 In other words, you have to tell your router to forward requests going to a specific port to your PC at port xyz.
换句话说,您必须告诉您的路由器将前往特定端口的请求转发到您的 PC 端口 xyz。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.