From 6180d6954c41a2412c166e5a9e8a2851cf39c6d1 Mon Sep 17 00:00:00 2001 From: Mikael Hallendal Date: Wed, 19 Feb 2003 08:13:31 +0000 Subject: 2003-02-19 Mikael Hallendal * 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. --- dbus/dbus-transport-unix.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'dbus/dbus-transport-unix.c') 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; +} /** @} */ -- cgit