how can i send images over internet without using socket connection in python

Viewed 18

I am trying to make a board-game in python named coup. i want this game to be online, so i can play it with my friend's in this game, there is a player named (Host) that he should give random card's to players. i had made this guy in python, but I cant send my card images over the net. i had searched the internet a lot, but the only answer i get was using socket library. but with this library we should all connect to a single internet modem, but we cant! some of my friends are in another cities or they are kilomiters away me! so they cant connect to my internet so here's my question: is there any way to send images without a single modem router? or can I use socket library over difrent connection's?

here is my (HOST) player code :

import socket
port = 13887                                 # random port (:
print ('port:   ',port)
for i in range (1,31):                       # I have 30  cards named 1.jpeg to 30.jpeg
    s = socket.socket ()
    host = socket.gethostname ()
    s.bind ((host,port))
    s.listen(1)
    conn, addr = s.accept()
    filename = 'python/'+str(i)+'.jpeg'     #my pictures are in a folder named python
    file = open(filename,'rb')
    file_data = file.read(160000)           # my pictures are at minimum 150000 bytes
    conn.send(file_data)
print ('transfer finished successfully')

other players (the recivers) code is :

import socket
from PIL import Image
port = 13887
for i in range (1,31):
    s = socket.socket ()
    host = 'D*****P-EV****R'             # sorry for hiding my host (: !!!
    s.connect((host,port))
    filename = 'python/'+str(i)+'.jpeg'
    file = open(filename ,'wb')
    file_data = s.recv(160000)
    file.write (file_data)
    file.close()
print ('files received! ')

when I run these code's in my and my brothers laptop, they work greatly (they are connected to the same Wifi) but when I send the code's to my friend's it cant work. what should I do?!

0 Answers
Related