8 parser = argparse.ArgumentParser(description=
'Simple socket client')
9 parser.add_argument(
"--port", default=8080, type=int)
10 parser.add_argument(
"--buffer-size", default=1024, type=int)
11 parser.add_argument(
"--size", default=256, type=int)
12 parser.add_argument(
"--rate", default=1, type=float)
13 parser.add_argument(
"--udp", action=
"store_true")
14 parser.add_argument(
"--ip", default=
"127.0.0.1")
15 args = parser.parse_args()
17 print "connecting to ", (args.ip, args.port)
21 server =
socket(AF_INET, SOCK_STREAM)
22 server.connect((args.ip, args.port))
25 packer = struct.Struct(
"!%ds" % args.size)
27 data = packer.pack((
"%d" % (counter % 10)) * args.size)
30 print "sending", packer.size * 8,
"bits" 32 server.sendto(data, (args.ip, args.port))
39 time.sleep(1 / args.rate)