### Method

# Gio DBusConnection send_message_with_reply

since: 2.26

#### Declaration

    void
    g_dbus_connection_send_message_with_reply (
      GDBusConnection* connection,
      GDBusMessage* message,
      GDBusSendMessageFlags flags,
      gint timeout_msec,
      volatile guint32* out_serial,
      GCancellable* cancellable,
      GAsyncReadyCallback callback,
      gpointer user_data
    )

#### Description

Asynchronously sends `message` to the peer represented by `connection`.

Unless `flags` contain the `G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL` flag, the serial number will be assigned by `connection` and set on `message` via g_dbus_message_set_serial(). If `out_serial` is not `NULL`, then the serial number used will be written to this location prior to submitting the message to the underlying transport. While it has a `volatile` qualifier, this is a historical artifact and the argument passed to it should not be `volatile`.

If `connection` is closed then the operation will fail with `G_IO_ERROR_CLOSED`. If `cancellable` is canceled, the operation will fail with `G_IO_ERROR_CANCELLED`. If `message` is not well-formed, the operation fails with `G_IO_ERROR_INVALID_ARGUMENT`.

This is an asynchronous method. When the operation is finished, `callback` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call `g_dbus_connection_send_message_with_reply_finish()` to get the result of the operation. See `g_dbus_connection_send_message_with_reply_sync()` for the synchronous version.

Note that `message` must be unlocked, unless `flags` contain the `G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL` flag.

See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.

Available since: 2.26

#### Parameters

`message`

  Type: `GDBusMessage`

  A `GDBusMessage`.

  The data is owned by the caller of the method.

`flags`

  Type: `GDBusSendMessageFlags`

  Flags affecting how the message is sent.

`timeout_msec`

  Type: `gint`

  The timeout in milliseconds, -1 to use the default timeout or `G_MAXINT` for no timeout.

`out_serial`

  Type: `volatile guint32*`

  Return location for serial number assigned to `message` when sending it or `NULL`.

  The argument will be set by the function.
  The argument can be `NULL`.

`cancellable`

  Type: `GCancellable`

  A `GCancellable` or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`callback`

  Type: `GAsyncReadyCallback`

  A `GAsyncReadyCallback` to call when the request is satisfied or `NULL` if you don’t care about the result.

  The argument can be `NULL`.

`user_data`

  Type: `gpointer`

  The data to pass to `callback`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.