MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / getData

Function getData

src/Test/BenchmarkSsl.py:75–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74
75def getData():
76 global total_num, total_bytes, clipher
77 data = None
78 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
79 # sock = socket.ssl(s)
80 # sock = ssl.wrap_socket(sock)
81 sock.connect(("127.0.0.1", 1234))
82 # sock.do_handshake()
83 # clipher = sock.cipher()
84 sock.send("gotssl\n")
85 if sock.recv(128) == "yes\n":
86 sock = ssl.wrap_socket(sock, ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1)
87 sock.do_handshake()
88 clipher = sock.cipher()
89
90 for req in range(20):
91 sock.sendall("req\n")
92 buff = StringIO.StringIO()
93 data = sock.recv(16 * 1024)
94 buff.write(data)
95 if not data:
96 break
97 while not data.endswith("\n"):
98 data = sock.recv(16 * 1024)
99 if not data:
100 break
101 buff.write(data)
102 total_num += 1
103 total_bytes += buff.tell()
104 if not data:
105 print("No data")
106
107 sock.shutdown(gevent.socket.SHUT_WR)
108 sock.close()
109
110s = time.time()
111

Callers

nothing calls this directly

Calls 5

connectMethod · 0.45
sendMethod · 0.45
writeMethod · 0.45
tellMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected