Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##
- # config
- ##
- port = 2727
- bindip = "192.168.0.17"
- ##
- # END
- ##
- import socket, sys, traceback, threading
- if __name__ == "__main__":
- sock = socket.socket()
- sock.bind((bindip, port))
- sock.listen(5)
- while True:
- try:
- rsock, address = sock.accept()
- f = None
- while True:
- d = rsock.recv(2048)
- if f and d[-5:] == "- EOF":
- f.write(d[:-5])
- f.close()
- f = None
- break
- elif f:
- f.write(d)
- elif d.find("-") != -1:
- f = open(d.split("-")[0].replace(" ", ""), "wb")
- f.write(d[d.index("-")+1:])
- except KeyboardInterrupt:
- print "Okayy"
- sock.close()
- sys.exit()
- except:
- traceback.print_exc()
Add Comment
Please, Sign In to add comment