Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //server.py
- #!/usr/bin/python
- import socket
- import sys
- s = socket.socket()
- host = socket.gethostname()
- port = 12345
- s.bind((host, port))
- s.listen(5)
- while True:
- sc, address = s.accept()
- print address
- i=1
- f = open('file_'+ str(i)+".png",'wb')
- i=i+1
- while (True):
- l = sc.recv(1024)
- while (l):
- f.write(l)
- l = sc.recv(1024)
- f.close()
- sc.close()
- s.close()
- //client.py
- #!/usr/bin/python
- import socket
- import sys
- s = socket.socket()
- host = socket.gethostname()
- port = 12345
- s.connect((host, port))
- f=open ("test.png", "rb")
- l = f.read(1024)
- while (l):
- s.send(l)
- l = f.read(1024)
- s.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement