Client connection handler. Serves as a basis for net.client.TCP and net.client.UDP.
Parameters: |
|
---|---|
Attribute async: | |
net.async.Async instance |
|
Callback onConnect(): | |
Callback if the client connects to its peer |
|
Callback onDisconnect(): | |
Callback if the client disconnects from its peer |
|
Callback onError(error): | |
Callback if an error occurs |
|
Callback onReceive(data): | |
Callback if data is received from the peer |
|
Callback onSend(data): | |
Callback if data is sent to the peer |
Send data to the client socket.
Parameters: |
|
---|
TCP client implementation:
>>> with TCP('127.0.0.1', 80, protocol='line', collect=True) as http:
... print >>http, 'GET / HTTP/1.1'
... print >>http, 'Host: localhost'
... print >>http, ''
... for line in http:
... print line
...
'HTTP/1.1 200 OK'
...
Parameters: |
|
---|
UDP client implementation:
>>> with UDP('127.0.0.1', 'echo', protocol='echo') as echo
... print >>echo, 'hello world'
... for line in echo:
... print line
...
'hello world'
Parameters: |
|
---|