-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.py
39 lines (28 loc) · 943 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Echo client program
import socket
HOST = '' # The remote host
PORT = 50008 # The same port as used by the server
if __name__ == '__main__':
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--filename",
metavar="FILE", help="write output to FILE")
parser.add_option("-i", "--ip",
metavar="FILE", help="write output to FILE")
parser.add_option("-p", "--port",
metavar="FILE", help="write output to FILE")
(options, args) = parser.parse_args()
filename = options.filename
ip = options.ip
port = options.port
_filename = filename.split('/')[-1]+'.copy'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, int(port)))
f = open(filename, 'rb')
data = f.read()
f.close()
data = 'FILENAME=%s=END=%s' % (_filename, data)
s.send(data)
s.close()