MCPcopy Create free account
hub / github.com/apache/trafficserver / tcp_client

Function tcp_client

tests/tools/tcp_client.py:26–39  ·  view source on GitHub ↗
(host, port, data, closeDelaySeconds=0)

Source from the content-addressed store, hash-verified

24
25
26def tcp_client(host, port, data, closeDelaySeconds=0):
27 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
28 s.connect((host, port))
29 s.sendall(data.encode())
30 if closeDelaySeconds > 0:
31 time.sleep(closeDelaySeconds)
32 s.shutdown(socket.SHUT_WR)
33 while True:
34 output = s.recv(4096) # suggested bufsize from docs.python.org
35 if len(output) <= 0:
36 break
37 else:
38 sys.stdout.write(output.decode())
39 s.close()
40
41
42DESCRIPTION =\

Callers 1

mainFunction · 0.70

Calls 7

connectMethod · 0.45
encodeMethod · 0.45
shutdownMethod · 0.45
recvMethod · 0.45
writeMethod · 0.45
decodeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected