Created
August 15, 2016 21:12
-
-
Save anonymous/8f70b3e2eca8606dee2c245ce64e9b63 to your computer and use it in GitHub Desktop.
Client server combo
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 = 1231 | |
s.connect((host, port)) | |
print (s.recv(1024)) | |
filename=input('Choose the file') | |
filez=''.join(filename) | |
s.send(filez.encode()) | |
f = open("texan.txt","wb+") | |
l = s.recv(1024) | |
print ("%s" % l) | |
while (l): | |
lm=str(l) | |
print (lm) | |
f.write(lm) | |
f.close() | |
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 | |
from os import listdir | |
import os | |
import random | |
invite=random.randint(1,100000) | |
key=random.randint(1,1000000) | |
combinedkey=str(key) + str(invite) + "\n" | |
keyfile=open('keylist.txt', 'a') | |
keyfile.write(combinedkey) | |
keyfile.close() | |
commondirectory='/home/communaldump/' | |
files=os.listdir(commondirectory) | |
filelist=''.join(files) | |
s=socket.socket() | |
host=socket.gethostname() | |
port=1231 | |
s.bind((host,port)) | |
s.listen(5) | |
while True: | |
conn,addr=s.accept() | |
print 'got connection from' | |
print "%s" % (addr,) | |
conn.send('Thank you for connecting') | |
conn.send("\n") | |
conn.send(filelist) | |
data = conn.recv(1024) | |
print "%s" % data | |
sdata=commondirectory+data | |
f=open(sdata,"wb+") | |
l=f.read(1024) | |
print l | |
while l: | |
conn.sendall(l) | |
data = conn.recv(1024) | |
f.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment