Package core :: Module net :: Class NetSocket

[hide private]
[frames] | no frames]

# Class NetSocket

source code

             object --+
                      |
     streams.ReadStream --+
                          |
             object --+   |
                      |   |
    streams.WriteStream --+
                          |
                         NetSocket

NetSocket is a socket-like abstraction used for reading from or writing to TCP connections.

Instance Methods | [hide private]

__init__(self, j_socket) | source code

write_buffer(self, buffer, handler=None) Write a Buffer to the socket. | source code

write_str(self, str, enc="UTF-8", handler=None) Write a String to the socket. | source code

closed_handler(self, handler) Set a closed handler on the socket. | source code

send_file(self, file_path) Tell the kernel to stream a file directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. | source code

close(self) Close the socket | source code

Inherited from `streams.ReadStream`: `data_handler`, `end_handler`, `exception_handler`, `pause`, `resume` Inherited from `streams.ReadStream` (private): `_to_read_stream` Inherited from `streams.WriteStream`: `drain_handler`, `set_write_queue_max_size`, `write_queue_full` Inherited from `streams.WriteStream` (private): `_to_write_stream`

Class Variables | [hide private]

Inherited from `streams.WriteStream`: `write_queue_max_size`

Method Details | [hide private]

### __init__(self, j_socket)
(Constructor)

source code

Overrides: object.__init__
  (inherited documentation)

### write_buffer(self, buffer, handler=None)

source code

Write a Buffer to the socket. The handler will be called when the buffer has actually been written to the wire.

Keyword arguments:

Parameters:
  - `buffer` - The buffer to write.
  - `handler` - The handler to call on completion.
Overrides: streams.WriteStream.write_buffer

### write_str(self, str, enc="UTF-8", handler=None)

source code

Write a String to the socket. The handler will be called when the string has actually been written to the wire.

Keyword arguments:

Parameters:
  - `str` - The string to write.
  - `enc` - The encoding to use.
  - `handler` - The handler to call on completion.

### closed_handler(self, handler)

source code

Set a closed handler on the socket.

Keyword arguments:

Parameters:
  - `handler` - A block to be used as the handler

### send_file(self, file_path)

source code

Tell the kernel to stream a file directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files.

Keyword arguments:

Parameters:
  - `file_path` - Path to file to send.