I can do simply socket communication on the same machine using
server:
import socket
s = socket.socket()
host = socket.socket()
port = 8000
s.bind((host,port))
s.listen(5)
while true:
c,addr = s.accept()
print 'got connection from', addr
c.send('thank you for connecting')
c.close()
client:
import socket
s = socket.socket()
host=socket.gethostname()
port = 8000
s.connect((host,port))
print s.recv(1024)
What changes would need to be made have this communicate between my laptop and a private server I work on? I have figured from my searching that portforwarding is the best way to go about it but haven’t found any explanations or tutorials on how to go about it.
thank you
If you care about Python port forwarding implementation, there’s an old but great ActriveState recipe that implements asynchronous port forwarding server using only Python standard library (socket, asyncore). You can poke around at code.activestate.com.
P.S.
There’s also a link to a threaded version of the script.