Module: cogen.core.sockets

Socket-only coroutine operations and Socket wrapper. Really - the only thing you need to know for most stuff is the Socket class.

Classes

Accept

Returns a (conn, addr) tuple when the operation completes.

Connect

Connect to the given addr using sock.

Read

len is max read size, BUT, if if there are buffers from ReadLine return them first. Example usage:

ReadAll

Run this operator till we've read len bytes.

ReadLine

Run this operator till we read a newline (n) or we have a overflow.

SendFile

Uses underling OS sendfile call or a regular memory copy operation if there is no sendfile. You can use this as a WriteAll if you specify the length. Usage:

Socket

A wrapper for socket objects, sets nonblocking mode and adds some internal bufers and wrappers. Regular calls to the usual socket methods return operations for use in a coroutine.

SocketOperation

This is a generic class for a operation that involves some socket call.

Write

Write the buffer to the socket and return the number of bytes written.

WriteAll

Run this operation till all the bytes have been written.

Functions

getdefaulttimeout ()

setdefaulttimeout (timeout)

Set the default timeout used by the socket wrapper (Socket class)