Python data transfer from a computer to another one (not local) without modifying router and fire wall Python

Viewed 28

Basically, i want to take data from pc A to send it to B (not local) in python

I tried using socket, then found out that its only working in local, except if you modify router / firewall. (atleast, its what i got from google) But i dont want to touch these things. So i would like to know, is there a way to send data to B like i want? because i cant really modify routers (if there is a way, but with another module, i still want to know)

Also, i dont care if i need to like switch my server code, and having another language or anything, i just want the client file in python, then a way to send data to another computer

my code with socket, if you know a way to send client's data to server:

# echo-client.py
import socket

inputKey = "hi"

#Data transferring via sockets

HOST = "" # The server's hostname or IP address
PORT = 65432  # The port used by the server

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    s.sendall(bytes(str(inputKey), encoding='utf-8'))
import socket


#Data receiving via sockets
HOST = ""  
PORT = 65432  


with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen()
    connexion, addr = s.accept()
    with connexion:
        print(f"Connected by {addr}")
        while True:
            data = connexion.recv(1024)
            if not data:
                break

            #printing in logs.txt
            with open("logs.txt","wb") as log:
                log.write(data)
0 Answers
Related