Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2016 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b789bf44fcd30c1bc721756346ce52a1 to your computer and use it in GitHub Desktop.
Save anonymous/b789bf44fcd30c1bc721756346ce52a1 to your computer and use it in GitHub Desktop.
simple file server in python
import socket
s=socket.socket()
host=socket.gethostname()
port=12345
s.connect((host,port))
while True:
f=open('conflict.png','wb')
data=s.recv(1024)
while (data):
f.write(data)
data=s.recv(1024)
f.close()
print('File successfully downloaded')
s.shutdown()
s.close()
import socket
port=12345
s=socket.socket()
host=socket.gethostname()
s.bind((host,port))
s.listen(5)
while (True):
conn, addr=s.accept()
filename='conflict.png'
f=open(filename,'rb')
l=f.read(1024)
while(l):
conn.send(l)
l=f.read(1024)
f.close()
conn.close()
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment