Created
December 18, 2016 04:45
-
-
Save anonymous/b789bf44fcd30c1bc721756346ce52a1 to your computer and use it in GitHub Desktop.
simple file server in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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