GIO Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
#include <gio/gio.h> GSocketConnection; GSocketAddress * g_socket_connection_get_local_address (GSocketConnection *connection
,GError **error
); GSocketAddress * g_socket_connection_get_remote_address (GSocketConnection *connection
,GError **error
); GSocket * g_socket_connection_get_socket (GSocketConnection *connection
); GSocketConnection * g_socket_connection_factory_create_connection (GSocket *socket
); GType g_socket_connection_factory_lookup_type (GSocketFamily family
,GSocketType type
,gint protocol_id
); void g_socket_connection_factory_register_type (GType g_type
,GSocketFamily family
,GSocketType type
,gint protocol
);
GObject +----GIOStream +----GSocketConnection +----GTcpConnection +----GUnixConnection
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.
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()
.
typedef struct _GSocketConnection GSocketConnection;
A socket connection GIOStream object for connection-oriented sockets.
Since 2.22
GSocketAddress * g_socket_connection_get_local_address (GSocketConnection *connection
,GError **error
);
Try to get the local address of a socket connection.
|
a GSocketConnection |
|
GError for error reporting, or NULL to ignore. |
Returns : |
a GSocketAddress or NULL on error.
Free the returned object with g_object_unref() . [transfer full]
|
Since 2.22
GSocketAddress * g_socket_connection_get_remote_address (GSocketConnection *connection
,GError **error
);
Try to get the remote address of a socket connection.
|
a GSocketConnection |
|
GError for error reporting, or NULL to ignore. |
Returns : |
a GSocketAddress or NULL on error.
Free the returned object with g_object_unref() . [transfer full]
|
Since 2.22
GSocket * g_socket_connection_get_socket (GSocketConnection *connection
);
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.
|
a GSocketConnection |
Returns : |
a GSocketAddress or NULL on error. [transfer none]
|
Since 2.22
GSocketConnection * g_socket_connection_factory_create_connection
(GSocket *socket
);
Creates a GSocketConnection subclass of the right type for
socket
.
|
a GSocket |
Returns : |
a GSocketConnection. [transfer full] |
Since 2.22
GType g_socket_connection_factory_lookup_type (GSocketFamily family
,GSocketType type
,gint protocol_id
);
Looks up the GType to be used when creating socket connections on
sockets with the specified family
,type
and protocol_id
.
If no type is registered, the GSocketConnection base type is returned.
|
a GSocketFamily |
|
a GSocketType |
|
a protocol id |
Returns : |
a GType |
Since 2.22
void g_socket_connection_factory_register_type (GType g_type
,GSocketFamily family
,GSocketType type
,gint protocol
);
Looks up the GType to be used when creating socket connections on
sockets with the specified family
,type
and protocol
.
If no type is registered, the GSocketConnection base type is returned.
|
a GType, inheriting from G_TYPE_SOCKET_CONNECTION
|
|
a GSocketFamily |
|
a GSocketType |
|
a protocol id |
Since 2.22