TCP echo client test has connect/disconnect capability
With '--size 0' or '--count 0' the test connects and disconnects quickly.
@@ -105,7 +105,8 @@ class TcpEchoClient:
total_sent = 0
total_rcvd = 0
- # outbound payload
+ if self.count > 0 and self.size > 0:
+ # outbound payload only if count and size both greater than zero
payload_out = []
out_list_idx = 0 # current _out array being sent
out_byte_idx = 0 # next-to-send in current array
@@ -134,6 +135,9 @@ class TcpEchoClient:
in_list_idx = 0 # current _in array being received
for i in range(self.count):
payload_in.append(bytearray())
+ else:
+ # when count or size .LE. zero then just connect-disconnect
+ self.keep_running = False
# set up connection
host_address = (self.host, self.port)
@@ -231,9 +235,9 @@ def main(argv):
p.add_argument('--port', '-p', type=int,
help='Required target port number')
p.add_argument('--size', '-s', type=int, default=100, const=1, nargs='?',
- help='Size of payload in bytes')
+ help='Size of payload in bytes must be >= 0. Size of zero connects and disconnects with no data traffic.')
p.add_argument('--count', '-c', type=int, default=1, const=1, nargs='?',
- help='Number of payloads to process')
+ help='Number of payloads to process must be >= 0. Count of zero connects and disconnects with no data traffic.')
p.add_argument('--name',
help='Optional logger prefix')
p.add_argument('--timeout', '-t', type=float, default=0.0, const=1, nargs="?",
@@ -255,13 +259,13 @@ def main(argv):
port = args.port
# size
- if args.size <= 0:
- raise Exception("Size must be greater than zero")
+ if args.size < 0:
+ raise Exception("Size must be greater than or equal to zero")
size = args.size
# count
- if args.count <= 0:
- raise Exception("Count must be greater than zero")
+ if args.count < 0:
+ raise Exception("Count must be greater than or equal to zero")
count = args.count
# name / prefix
