Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Connect to the server as a client
- import zlib
- import logging
- import SocketServer
- import binascii
- logger.info('Contacting server on %s:%s', ip, port)
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((ip, port))
- # Ask for a file
- requested_file = 'lorem.txt'
- logger.debug('sending filename: "%s"', requested_file)
- len_sent = s.send(requested_file)
- # Receive a response
- buffer = StringIO()
- decompressor = zlib.decompressobj()
- while True:
- response = s.recv(BLOCK_SIZE)
- if not response:
- break
- logger.debug('READ "%s"', binascii.hexlify(response))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement