toko214

client both

Feb 26th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import socket               # Import socket module
  2.  
  3. s = socket.socket()         # Create a socket object
  4. host = '192.168.1.108' # Get local machine name
  5. port = 80                # Reserve a port for your service.
  6. postr="POST /upload/file-name=tosend.jpg HTTP /1.1"
  7. s.connect((host, port))
  8. f = open('tosend.jpg','rb')
  9. l = f.read(1024)
  10. print 'Sending...'
  11. s.send(postr)
  12. while(l):
  13.    s.send(l)
  14.    l=f.read(1024)
  15. f.close()
  16. print "Done Sending"
  17. s.shutdown(socket.SHUT_WR)
  18. print s.recv(1024)
  19. s.close                     # Close the socket when done
Add Comment
Please, Sign In to add comment