circuits.net.sockets – Socket Components — circuits 2.1.0 documentation

# circuits 2.1.0 documentation

# `circuits.net.sockets` – Socket Components

## Events

class `circuits.net.sockets.` `Connect`(*args, **kwargs)

  Bases: `circuits.core.events.Event`

  Connect Event

  This Event is sent when a new client connection has arrived on a server. This event is also used for client’s to initiate a new connection to a remote host.

  Note

  This event is used for both Client and Server Components.

  Parameters: | args (tuple) – Client: (host, port) Server: (sock, host, port) kwargs (dict) – Client: (ssl)

class `circuits.net.sockets.` `Connected`(host, port)

  Bases: `circuits.core.events.Event`

  Connected Event

  This Event is sent when a client has successfully connected.

  @note: This event is for Client Components.

  Parameters: | host – The hostname connected to. port – The port connected to

class `circuits.net.sockets.` `Close`(*args)

  Bases: `circuits.core.events.Event`

  Close Event

  This Event is used to notify a client, client connection or server that we want to close.

  @note: This event is never sent, it is used to close. @note: This event is used for both Client and Server Components.

  Parameters: | args – Client: () Server: (sock)

class `circuits.net.sockets.` `Closed`

  Bases: `circuits.core.events.Event`

  Closed Event

  This Event is sent when a server has closed its listening socket.

  @note: This event is for Server components.

class `circuits.net.sockets.` `Read`(*args)

  Bases: `circuits.core.events.Event`

  Read Event

  This Event is sent when a client or server connection has read any data.

  @note: This event is used for both Client and Server Components.

  Parameters: | args – Client: (data) Server: (sock, data)

class `circuits.net.sockets.` `Write`(*args)

  Bases: `circuits.core.events.Event`

  Write Event

  This Event is used to notify a client, client connection or server that we have data to be written.

  @note: This event is never sent, it is used to send data. @note: This event is used for both Client and Server Components.

  Parameters: | args – Client: (data) Server: (sock, data)

class `circuits.net.sockets.` `SocketError`(*args)

  Bases: `circuits.core.events.Event`

  SocketError Event

  This Event is sent when a client or server connection has an error.

  @note: This event is used for both Client and Server Components.

  Parameters: | args – Client: (error) Server: (sock, error)

class `circuits.net.sockets.` `Disconnect`(*args)

  Bases: `circuits.core.events.Event`

  Disconnect Event

  This Event is sent when a client connection has closed on a server. This event is also used for client’s to disconnect from a remote host.

  @note: This event is used for both Client and Server Components.

  Parameters: | args – Client: () Server: (sock)

class `circuits.net.sockets.` `Disconnected`

  Bases: `circuits.core.events.Event`

  Disconnected Event

  This Event is sent when a client has disconnected

  @note: This event is for Client Components.

## Components

class `circuits.net.sockets.` `Client`(bind=None, bufsize=4096, channel='client')

  Bases: `circuits.core.components.BaseComponent`

  `channel` = 'client'
  `parse_bind_parameter`(bind_parameter)
  `connected`
  `close`()
  `write`(data)

class `circuits.net.sockets.` `TCPClient`(bind=None, bufsize=4096, channel='client')

  Bases: `circuits.net.sockets.Client`

  `socket_family` = 2
  `connect`(host, port, secure=False, **kwargs)

`circuits.net.sockets.` `UDPClient`

  alias of `UDPServer`

class `circuits.net.sockets.` `UNIXClient`(bind=None, bufsize=4096, channel='client')

  Bases: `circuits.net.sockets.Client`

  `ready`(component)
  `connect`(path, secure=False, **kwargs)

class `circuits.net.sockets.` `Server`(bind, secure=False, backlog=5000, bufsize=4096, channel='server', **kwargs)

  Bases: `circuits.core.components.BaseComponent`

  `channel` = 'server'
  `parse_bind_parameter`(bind_parameter)
  `connected`
  `host`
  `port`
  `close`(sock=None)
  `write`(sock, data)

class `circuits.net.sockets.` `TCPServer`(bind, secure=False, backlog=5000, bufsize=4096, channel='server', **kwargs)

  Bases: `circuits.net.sockets.Server`

  `socket_family` = 2
  `parse_bind_parameter`(bind_parameter)

class `circuits.net.sockets.` `UDPServer`(bind, secure=False, backlog=5000, bufsize=4096, channel='server', **kwargs)

  Bases: `circuits.net.sockets.Server`

  `socket_family` = 2
  `close`()
  `write`(address, data)
  `broadcast`(data, port)

class `circuits.net.sockets.` `UNIXServer`(bind, secure=False, backlog=5000, bufsize=4096, channel='server', **kwargs)

  Bases: `circuits.net.sockets.Server`

## Functions

`circuits.net.sockets.` `Pipe`(*channels, **kwargs)

  Create a new full duplex Pipe

  Returns a pair of UNIXClient instances connected on either side of the pipe.