summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport-unix.c
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2003-02-19 08:13:31 +0000
committerMikael Hallendal <micke@codefactory.se>2003-02-19 08:13:31 +0000
commit6180d6954c41a2412c166e5a9e8a2851cf39c6d1 (patch)
tree0309901a7c3eede8a578332b9a7b419dc977cfd3 /dbus/dbus-transport-unix.c
parentc21511c01ab56d75f3aa4643761e9fd096a7f8be (diff)
2003-02-19 Mikael Hallendal <micke@codefactory.se>
* dbus/dbus-server.c (dbus_server_listen): Support tcp: addresses. * dbus/dbus-transport-unix.c (_dbus_transport_new_for_tcp_socket): Added to create a transport connecting using a tcp/ip socket. * dbus/dbus-sysdeps.c (_dbus_connect_tcp_socket): Added to connect to a tcp socket at given host and port. (_dbus_listen_tcp_socket): added to listen on tcp socket for given hostname and port. * dbus/dbus-server.c (dbus_server_listen): Support tcp: addresses. * dbus/dbus-server-unix.c (_dbus_server_new_for_tcp_socket): Added to create a server listening on a TCP/IP socket.
Diffstat (limited to 'dbus/dbus-transport-unix.c')
-rw-r--r--dbus/dbus-transport-unix.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c
index 84703345..c5dce8d7 100644
--- a/dbus/dbus-transport-unix.c
+++ b/dbus/dbus-transport-unix.c
@@ -1118,6 +1118,43 @@ _dbus_transport_new_for_domain_socket (const char *path,
return transport;
}
+/**
+ * Creates a new transport for the given hostname and port.
+ *
+ * @param host the host to connect to
+ * @param port the port to connect to
+ * @param server #TRUE if this transport is on the server side of a connection
+ * @param result location to store reason for failure.
+ * @returns a new transport, or #NULL on failure.
+ */
+DBusTransport*
+_dbus_transport_new_for_tcp_socket (const char *host,
+ dbus_int32_t port,
+ dbus_bool_t server,
+ DBusResultCode *result)
+{
+ int fd;
+ DBusTransport *transport;
+
+ fd = _dbus_connect_tcp_socket (host, port, result);
+ if (fd < 0)
+ return NULL;
+
+ _dbus_fd_set_close_on_exec (fd);
+
+ _dbus_verbose ("Successfully connected to tcp socket %s:%d\n",
+ host, port);
+
+ transport = _dbus_transport_new_for_fd (fd, server);
+ if (transport == NULL)
+ {
+ dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
+ close (fd);
+ fd = -1;
+ }
+
+ return transport;
+}
/** @} */