I am working on a script that would transmit the data between two distinct computers with access to the internet. I am using python's socket standard module. It works fine when I run both client and server on single computer but I am not able to make the things work when they run on different computers.
Here is a part of my server code:
import socket, time,os, random class Server(): def __init__(self,Adress=('',5000),MaxClient=1): self.s = socket.socket() self.s.bind(Adress) self.s.listen(MaxClient) def WaitForConnection(self): self.Client, self.Adr=(self.s.accept()) print('Got a connection from: '+str(self.Client)+'.') s = Server() s.WaitForConnection()
And here is a part of my client code:
import socket class Client(): def __init__(self,Adress=("Here is the IP of the computer on which the \ server scrip is running",5000)): self.s = socket.socket() self.s.connect(Adress) c = Client()
When I run these scripts on two different computers with internet access the client is unable to connect and raises an error and the server is waiting for connections forever.
What am I doing wrong?