Infinity.TcpConnection¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The index of the device to use for the connection |
||
r/w |
The name of the device to use for the connection, such as `eth0’ |
||
r/w/co |
I/O handler |
||
r/w |
The keepalive settings for the connection |
||
r |
The local address of the connection |
||
r |
The local port of the connection |
||
r/w |
Address to connect to |
||
r/w |
Port to connect to |
||
r/w/c |
The hostname resolver |
||
r |
Status of the TCP connection |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted when an error occurred with the connection. |
|
This signal is emitted whenever data has been received from the connection. |
|
This signal is emitted whenever data has been sent over the connection. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Infinity.TcpConnection(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Infinity.TcpConnection
is an opaque data type. You should only access it via the public API functions.- classmethod new(io, remote_addr, remote_port)¶
- Parameters:
io (
Infinity.Io
) – AInfinity.Io
object used to watch for activity.remote_addr (
Infinity.IpAddress
) – The address to eventually connect to.remote_port (
int
) – The port to eventually connect to.
- Returns:
A new
Infinity.TcpConnection
. Free withGObject.Object.unref
().- Return type:
Creates a new
Infinity.TcpConnection
. The arguments are stored as properties for an eventualInfinity.TcpConnection.open
() call, this function itself does not establish a connection.
- classmethod new_and_open(io, remote_addr, remote_port)¶
- Parameters:
io (
Infinity.Io
) – AInfinity.Io
object used to watch for activity.remote_addr (
Infinity.IpAddress
) – The address to connect to.remote_port (
int
) – The port to connect to.
- Raises:
- Returns:
A new
Infinity.TcpConnection
, orNone
on error. Free withGObject.Object.unref
().- Return type:
Creates a new
Infinity.TcpConnection
and connects it to the given TCP endpoint. LikeInfinity.TcpConnection.new
(), but callsInfinity.TcpConnection.open
().
- classmethod new_resolve(io, resolver)¶
- Parameters:
io (
Infinity.Io
) – AInfinity.Io
object used to watch for activity.resolver (
Infinity.NameResolver
) – The hostname resolver object used to look up the remote hostname.
- Returns:
A new
Infinity.TcpConnection
. Free withGObject.Object.unref
().- Return type:
Creates a new
Infinity.TcpConnection
and instead of setting the remote IP address and port number directly, a hostname resolver is used to look up the remote hostname before connecting. This has the advantage that all available addresses for that hostname are tried before giving up.The argument is stored as a property for an eventual
Infinity.TcpConnection.open
() call, this function itself does not establish a connection.
- close()¶
Closes a TCP connection that is either open or currently connecting.
- get_keepalive()¶
- Returns:
The current keepalive configuration for self, owned by self.
- Return type:
Returns the current keepalive settings for self.
- get_remote_address()¶
- Returns:
A
Infinity.IpAddress
owned by self. You do not need to free it, but need to make your own copy if you want to keep it longer than self's lifetime.- Return type:
Returns the IP address of the remote site.
- get_remote_port()¶
- Returns:
The port of the remote site.
- Return type:
Returns the port of the remote site to which self is (or was) connected or connecting.
- open()¶
- Raises:
- Returns:
- Return type:
Attempts to open self. Make sure to have set the “remote-address” and “remote-port” property before calling this function. If an error occurs, the function returns
False
and error is set. Note however that the connection might not be fully open when the function returns (check the “status” property if you need to know). If an asynchronous error occurs while the connection is being opened, the “error” signal is emitted.
- send(data)¶
- Parameters:
data (
bytes
) – The data to send.
Sends data through the TCP connection. The data is not sent immediately, but enqueued to a buffer and will be sent as soon as kernel space becomes available. The “sent” signal will be emitted when data has really been sent.
- set_keepalive(keepalive)¶
- Parameters:
keepalive (
Infinity.Keepalive
) – New keepalive settings for the connection.- Raises:
- Returns:
True
if the new keeplalive values were set, orFalse
on error.- Return type:
Sets the keepalive settings for self. When this function is not called, the system defaults are used. If the connection is closed, then the function always succeeds and stores the keepalive values internally. The values are actually set on the underlying socket when the connection is opened. If the connection is already open, the function might fail if the system call fails.
- do_error(error) virtual¶
- Parameters:
error (
GLib.Error
) –
Signal Details¶
- Infinity.TcpConnection.signals.error(tcp_connection, error)¶
- Signal Name:
error
- Flags:
- Parameters:
tcp_connection (
Infinity.TcpConnection
) – The object which received the signalerror (
GLib.Error
) – A pointer to aGLib.Error
object with details on the error.
This signal is emitted when an error occurred with the connection. If the error is fatal, the connection will change its status to
Infinity.TcpConnectionStatus.CLOSED
.
- Infinity.TcpConnection.signals.received(tcp_connection, data, length)¶
- Signal Name:
received
- Flags:
- Parameters:
This signal is emitted whenever data has been received from the connection.
- Infinity.TcpConnection.signals.sent(tcp_connection, data, length)¶
- Signal Name:
sent
- Flags:
- Parameters:
This signal is emitted whenever data has been sent over the connection.
Property Details¶
- Infinity.TcpConnection.props.device_index¶
-
The index of the device to use for the connection
- Infinity.TcpConnection.props.device_name¶
-
The name of the device to use for the connection, such as `eth0’
- Infinity.TcpConnection.props.io¶
- Name:
io
- Type:
- Default Value:
- Flags:
I/O handler
- Infinity.TcpConnection.props.keepalive¶
- Name:
keepalive
- Type:
- Default Value:
- Flags:
The keepalive settings for the connection
- Infinity.TcpConnection.props.local_address¶
- Name:
local-address
- Type:
- Default Value:
- Flags:
The local address of the connection
- Infinity.TcpConnection.props.local_port¶
-
The local port of the connection
- Infinity.TcpConnection.props.remote_address¶
- Name:
remote-address
- Type:
- Default Value:
- Flags:
Address to connect to
- Infinity.TcpConnection.props.remote_port¶
-
Port to connect to
- Infinity.TcpConnection.props.resolver¶
- Name:
resolver
- Type:
- Default Value:
- Flags:
The hostname resolver
- Infinity.TcpConnection.props.status¶
- Name:
status
- Type:
- Default Value:
- Flags:
Status of the TCP connection