# Gio::SocketConnection Class Reference
[Portable Network I/O Functionality]

A socket connection. More...

`#include <giomm/socketconnection.h>`

Inheritance diagram for Gio::SocketConnection:
[legend]

List of all members.

## Public Member Functions

virtual | ~SocketConnection ()
GSocketConnection* | gobj ()
| Provides access to the underlying C GObject.
const GSocketConnection* | gobj () const
| Provides access to the underlying C GObject.
GSocketConnection* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::RefPtr< Socket > | get_socket ()
| Gets the underlying Socket object of the connection.
Glib::RefPtr< const Socket > | get_socket () const
| Gets the underlying Socket object of the connection.
Glib::RefPtr< SocketAddress > | get_local_address ()
| Try to get the local address of a socket connection.
Glib::RefPtr< const SocketAddress > | get_local_address () const
| Try to get the local address of a socket connection.
Glib::RefPtr< SocketAddress > | get_remote_address ()
| Try to get the remote address of a socket connection.
Glib::RefPtr< const SocketAddress > | get_remote_address () const
| Try to get the remote address of a socket connection.
Glib::PropertyProxy_ReadOnly < Glib::RefPtr< Socket > > | property_socket () const
| The underlying GSocket.

## Static Public Member Functions

static Glib::RefPtr < SocketConnection > | create (const Glib::RefPtr< Socket >& socket)
| Creates a SocketConnection subclass of the right type for socket.

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr < Gio::SocketConnection > | wrap (GSocketConnection* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A socket connection.

See also:
  IOStream, SocketClient, SocketListener

SocketConnection is a IOStream for a connected socket. They can be created either by SocketClient when connecting to a host, or by SocketListener when accepting a new client.

The type of the SocketConnection 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 TcpConnection.

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

Since glibmm 2.24:

## Constructor & Destructor Documentation

virtual Gio::SocketConnection::~SocketConnection | ( |  | ) | `[virtual]`

## Member Function Documentation

static Glib::RefPtr<SocketConnection> Gio::SocketConnection::create | ( | const Glib::RefPtr< Socket >& | socket | ) | `[static]`

Creates a SocketConnection subclass of the right type for socket.

Since glibmm 2.22:

Returns:
  A SocketConnection.

Glib::RefPtr<const SocketAddress> Gio::SocketConnection::get_local_address | ( |  | ) | const

Try to get the local address of a socket connection.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error. Free the returned object with Glib::object_unref().

Glib::RefPtr<SocketAddress> Gio::SocketConnection::get_local_address | ( |  | ) |

Try to get the local address of a socket connection.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error. Free the returned object with Glib::object_unref().

Glib::RefPtr<const SocketAddress> Gio::SocketConnection::get_remote_address | ( |  | ) | const

Try to get the remote address of a socket connection.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error. Free the returned object with Glib::object_unref().

Glib::RefPtr<SocketAddress> Gio::SocketConnection::get_remote_address | ( |  | ) |

Try to get the remote address of a socket connection.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error. Free the returned object with Glib::object_unref().

Glib::RefPtr<const Socket> Gio::SocketConnection::get_socket | ( |  | ) | const

Gets the underlying Socket object of the connection.

This can be useful if you want to do something unusual on it not supported by the SocketConnection APIs.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error.

Glib::RefPtr<Socket> Gio::SocketConnection::get_socket | ( |  | ) |

Gets the underlying Socket object of the connection.

This can be useful if you want to do something unusual on it not supported by the SocketConnection APIs.

Since glibmm 2.22:

Returns:
  A SocketAddress or `0` on error.

const GSocketConnection* Gio::SocketConnection::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::IOStream.

Reimplemented in Gio::TcpConnection, and Gio::UnixConnection.

GSocketConnection* Gio::SocketConnection::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::IOStream.

Reimplemented in Gio::TcpConnection, and Gio::UnixConnection.

GSocketConnection* Gio::SocketConnection::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gio::IOStream.

Reimplemented in Gio::TcpConnection, and Gio::UnixConnection.

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Socket> > Gio::SocketConnection::property_socket | ( |  | ) | const

The underlying GSocket.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::SocketConnection > wrap | ( | GSocketConnection * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.