当客户端和服务器位于不同的网络上时,我想使用此代码。 pythons套接字可以做到这一点吗?
服务器:
<policyEntry queue=">" producerFlowControl="false" memoryLimit="10 mb">
</policyEntry>
客户端:
import socket
import select
open_client_sockets = []
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 8001))
server_socket.listen(1)
(new_socket1, address1) = server_socket.accept()
open_client_sockets.append(new_socket1)
while True:
rlist, wlist, xlist = select.select(open_client_sockets,
open_client_sockets, [])
for current_socket in rlist:
data = current_socket.recv(4096)
if data != '':
print "given data: ", str(data)
仅在同一网络上工作。