-/**
- * Creates a new server listening on the given hostname and port.
- * If the hostname is NULL, listens on localhost.
- *
- * @param host the hostname to listen on.
- * @param port the port to listen on.
- * @param error location to store reason for failure.
- * @returns the new server, or #NULL on failure.
- */
-DBusServer*
-_dbus_server_new_for_tcp_socket (const char *host,
- dbus_uint32_t port,
- DBusError *error)
-{
- DBusServer *server;
- int listen_fd;
- DBusString address;
-
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
- if (!_dbus_string_init (&address))
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return NULL;
- }
-
- if (!_dbus_string_append (&address, "tcp:host=") ||
- !_dbus_string_append (&address, host) ||
- !_dbus_string_append (&address, ",port=") ||
- !_dbus_string_append_int (&address, port))
- {
- _dbus_string_free (&address);
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- return NULL;
- }
-
- listen_fd = _dbus_listen_tcp_socket (host, port, error);
- _dbus_fd_set_close_on_exec (listen_fd);
-
- if (listen_fd < 0)
- {
- _dbus_string_free (&address);
- return NULL;
- }
-
- server = _dbus_server_new_for_fd (listen_fd, &address);
- if (server == NULL)
- {
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- close (listen_fd);
- _dbus_string_free (&address);
- return NULL;
- }
-
- _dbus_string_free (&address);
-
- return server;
-
-
-}
-