Example #1
0
def run():
    cs = _test.init_contexts()

    for ctx in cs:
        print "google test"
        _test.google_client_test(ctx)
        print "thread test"
        _test.thread_network_test(cs[0])

        p = multiprocessing.Process(target=_test.run_one_server, args=(0, logf))
        p.daemon = True
        p.start()
        time.sleep(0.3)
        _test.run_one_client(cs[0], logf)
Example #2
0
def run():
    cs = _test.init_contexts()

    for ctx in cs:
        print "google test"
        _test.google_client_test(ctx)
        print "thread test"
        _test.thread_network_test(cs[0])

        p = multiprocessing.Process(target=_test.run_one_server,
                                    args=(0, logf))
        p.daemon = True
        p.start()
        time.sleep(0.3)
        _test.run_one_client(cs[0], logf)
Example #3
0
import socket

import test
import _test
from cyopenssl import *


contexts = _test.init_contexts()
ctx = contexts[0]


s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind( ('127.100.100.1', 8888) )
s.listen(300)
c, a = s.accept()
c.settimeout(0.1)  # localhost should be very fast
c2 = Socket(c, ctx, server_side=True)

req = c2.recv(1024)
bytes_recvd = 0
while req:
    bytes_recvd += len(req)
    c2.send(req)
    req = c2.recv(1024)

c2.shutdown(socket.SHUT_RDWR)
s.close()
Example #4
0
import socket

import test
import _test
from cyopenssl import *

contexts = _test.init_contexts()
ctx = contexts[0]
N_SEND = 1000

s = socket.create_connection( ('127.100.100.1', 8888) )
s2 = Socket(s, ctx)
s2.send('test')
s2.recv(4)
start = time.time()
for i in range(N_SEND):
	s2.send('test')
	s2.recv(4)
finish = time.time()
s2.shutdown(socket.SHUT_RDWR)

print "{0:0.2f}us per SSL echo".format(1e6 * (finish - start) / N_SEND)