-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
executable file
·28 lines (23 loc) · 958 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
#!/usr/bin/python3
from argparse import ArgumentParser
import swp
import logging
import sys
def main():
# Parse arguments
arg_parser = ArgumentParser(description='Client', add_help=False)
arg_parser.add_argument('-p', '--port', dest='port', action='store',
type=int, required=True, help='Remote port')
arg_parser.add_argument('-h', '--hostname', dest='hostname', action='store',
type=str, required=True, help='Remote hostname')
arg_parser.add_argument('-l', '--loss', dest='loss_probability',
action='store', type=float, default=0.0, help='Loss probability')
settings = arg_parser.parse_args()
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)s: %(message)s')
sender = swp.SWPSender((settings.hostname, settings.port),
settings.loss_probability)
for line in sys.stdin:
sender.send(line.encode())
if __name__ == '__main__':
main()