| Top |
UnixUnix — Unix socket |
#include <gnet.h>
GUnixSocket;
GUnixSocket* gnet_unix_socket_new (const gchar *path);
GUnixSocket* gnet_unix_socket_new_abstract (const gchar *path);
void gnet_unix_socket_delete (GUnixSocket *socket);
void gnet_unix_socket_ref (GUnixSocket *socket);
void gnet_unix_socket_unref (GUnixSocket *socket);
GIOChannel * gnet_unix_socket_get_io_channel (GUnixSocket *socket);
gchar * gnet_unix_socket_get_path (const GUnixSocket *socket);
GUnixSocket* gnet_unix_socket_server_new (const gchar *path);
GUnixSocket* gnet_unix_socket_server_new_abstract
(const gchar *path);
GUnixSocket* gnet_unix_socket_server_accept (const GUnixSocket *socket);
GUnixSocket* gnet_unix_socket_server_accept_nonblock
(const GUnixSocket *socket);
The Unix module provides support for Unix sockets. Unix sockets are used to communicate between processes. Unix sockets are for Unix operating systems only and are not supported in Windows. GNet's Unix sockets are stream-based (like TCP), not datagram-based (like UDP). Unix socket addresses are file names, like "/tmp/my_unix_socket".
To connect to a existing Unix socket, call gnet_unix_socket_new(). To
create a new Unix socket other processes will connect to, call
gnet_unix_socket_server_new().
The functions in this module are similar to those in the TCP module. See the documentation on TCP sockets for more information.
typedef struct _GUnixSocket GUnixSocket;
A GUnixSocket structure represents a Unix socket. The implementation is hidden.
GUnixSocket* gnet_unix_socket_new (constgchar *path);
Creates a GUnixSocket and connects to path. This function will
block to connect. Use this constructor to create a GUnixSocket
for a client.
|
path |
Returns : |
a new GUnixSocket; NULL on failure. |
GUnixSocket* gnet_unix_socket_new_abstract (constgchar *path);
Creates a GUnixSocket and connects to path in the abstract
unix socket domain. This function will block to connect. Use this
constructor to create a GUnixSocket for a client.
If the abstract unix sockets are not available on the platform in use,
this function will behave like gnet_unix_socket_new().
|
path |
Returns : |
a new GUnixSocket, or NULL on failure. |
Since 2.0.8
void gnet_unix_socket_delete (GUnixSocket *socket);
Deletes a GUnixSocket.
|
a GUnixSocket |
void gnet_unix_socket_ref (GUnixSocket *socket);
Adds a reference to a GUnixSocket.
|
a GUnixSocket |
void gnet_unix_socket_unref (GUnixSocket *socket);
Removes a reference from a GUnixSocket. A GUnixSocket is deleted when the reference count reaches 0.
|
a GUnixSocket |
GIOChannel * gnet_unix_socket_get_io_channel (GUnixSocket *socket);
Gets the
For a client socket, the
For a server socket, however, the
Every GUnixSocket has one and only one
|
a GUnixSocket |
Returns : |
a |
gchar * gnet_unix_socket_get_path (const GUnixSocket *socket);
Gets the path of a GUnixSocket.
|
a GUnixSocket |
Returns : |
the path. |
GUnixSocket* gnet_unix_socket_server_new (constgchar *path);
Creates a GUnixSocket bound to path. Use this constructor to
create a GUnixSocket for a server.
|
path |
Returns : |
a new GUnixSocket; NULL on error. |
GUnixSocket* gnet_unix_socket_server_new_abstract (constgchar *path);
Creates a GUnixSocket bound to path in the abstract unix socket
domain. Use this constructor to create a GUnixSocket for a
server.
If the abstract unix sockets are not available on the platform in use,
this function will behave the same as gnet_unix_socket_server_new().
|
path |
Returns : |
a new GUnixSocket, or NULL on error. |
Since 2.0.8
GUnixSocket* gnet_unix_socket_server_accept (const GUnixSocket *socket);
Accepts a connection from a GUnixSocket. The socket must have
been created using gnet_unix_socket_server_new(). This function
will block. Even if the socket's
|
a GUnixSocket |
Returns : |
a new GUnixSocket representing a new connection; NULL on error. |
GUnixSocket* gnet_unix_socket_server_accept_nonblock (const GUnixSocket *socket);
Accepts a connection from a GUnixSocket without blocking. The
socket must have been created using gnet_unix_socket_server_new().
Note that if the socket's
|
a GUnixSocket |
Returns : |
a new GUnixSocket representing a new connection; NULL otherwise. |