Gio.SocketConnection
Description: Reference for Gio.SocketConnection

### Class

# GioSocketConnection

since: 2.22

#### Description [src]

    class Gio.SocketConnection : Gio.IOStream
    {
      priv: GSocketConnectionPrivate*
    }

`GSocketConnection` is a `GIOStream` for a connected socket. They can be created either by `GSocketClient` when connecting to a host, or by `GSocketListener` when accepting a new client.

The type of the `GSocketConnection` object returned from these calls depends on the type of the underlying socket that is in use. For instance, for a TCP/IP connection it will be a `GTcpConnection`.

Choosing what type of object to construct is done with the socket connection factory, and it is possible for third parties to register custom socket connection types for specific combination of socket family/type/protocol using `g_socket_connection_factory_register_type()`.

To close a `GSocketConnection`, use `g_io_stream_close()`. Closing both substreams of the `GIOStream` separately will not close the underlying `GSocket`.

Available since: 2.22

#### Hierarchy

#### Ancestors

- GIOStream
- GObject

#### Descendants

- GTcpConnection
- GUnixConnection

#### Functions

###### g_socket_connection_factory_lookup_type

Looks up the `GType` to be used when creating socket connections on sockets with the specified `family`, `type` and `protocol_id`.

since: 2.22

###### g_socket_connection_factory_register_type

Looks up the `GType` to be used when creating socket connections on sockets with the specified `family`, `type` and `protocol`.

since: 2.22

#### Instance methods

###### g_socket_connection_connect

Connect `connection` to the specified remote address.

since: 2.32

###### g_socket_connection_connect_async

Asynchronously connect `connection` to the specified remote address.

since: 2.32

###### g_socket_connection_connect_finish

Gets the result of a `g_socket_connection_connect_async()` call.

since: 2.32

###### g_socket_connection_get_local_address

Try to get the local address of a socket connection.

since: 2.22

###### g_socket_connection_get_remote_address

Try to get the remote address of a socket connection.

since: 2.22

###### g_socket_connection_get_socket

Gets the underlying `GSocket` object of the connection. This can be useful if you want to do something unusual on it not supported by the `GSocketConnection` APIs.

since: 2.22

###### g_socket_connection_is_connected

Checks if `connection` is connected. This is equivalent to calling `g_socket_is_connected()` on `connection`‘s underlying `GSocket`.

since: 2.32

##### Methods inherited from GIOStream (10)

###### g_io_stream_clear_pending

Clears the pending flag on `stream`.

since: 2.22

###### g_io_stream_close

Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed.

since: 2.22

###### g_io_stream_close_async

Requests an asynchronous close of the stream, releasing resources related to it. When the operation is finished `callback` will be called. You can then call `g_io_stream_close_finish()` to get the result of the operation.

since: 2.22

###### g_io_stream_close_finish

Closes a stream.

since: 2.22

###### g_io_stream_get_input_stream

Gets the input stream for this object. This is used for reading.

since: 2.22

###### g_io_stream_get_output_stream

Gets the output stream for this object. This is used for writing.

since: 2.22

###### g_io_stream_has_pending

Checks if a stream has pending actions.

since: 2.22

###### g_io_stream_is_closed

Checks if a stream is closed.

since: 2.22

###### g_io_stream_set_pending

Sets `stream` to have actions pending. If the pending flag is already set or `stream` is closed, it will return `FALSE` and set `error`.

since: 2.22

###### g_io_stream_splice_async

Asynchronously splice the output stream of `stream1` to the input stream of `stream2`, and splice the output stream of `stream2` to the input stream of `stream1`.

since: 2.28

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Gio.SocketConnection:socket

The underlying `GSocket`.

since: 2.22

##### Properties inherited from GIOStream (3)

###### Gio.IOStream:closed

Whether the stream is closed.

since: 2.22

###### Gio.IOStream:input-stream

The `GInputStream` to read from.

since: 2.22

###### Gio.IOStream:output-stream

The `GOutputStream` to write to.

since: 2.22

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GioSocketConnectionClass {
      GIOStreamClass parent_class;
      void (* _g_reserved1) (
    void
      );
      void (* _g_reserved2) (
    void
      );
      void (* _g_reserved3) (
    void
      );
      void (* _g_reserved4) (
    void
      );
      void (* _g_reserved5) (
    void
      );
      void (* _g_reserved6) (
    void
      );

    }

No description available.

###### Class members

`parent_class: GIOStreamClass`

  No description available.

`_g_reserved1: void (* _g_reserved1) ( void )`

  No description available.

`_g_reserved2: void (* _g_reserved2) ( void )`

  No description available.

`_g_reserved3: void (* _g_reserved3) ( void )`

  No description available.

`_g_reserved4: void (* _g_reserved4) ( void )`

  No description available.

`_g_reserved5: void (* _g_reserved5) ( void )`

  No description available.

`_g_reserved6: void (* _g_reserved6) ( void )`

  No description available.