### Constructor

# Gio DBusConnection new_sync

since: 2.26

#### Declaration [src]

    GDBusConnection*
    g_dbus_connection_new_sync (
      GIOStream* stream,
      const gchar* guid,
      GDBusConnectionFlags flags,
      GDBusAuthObserver* observer,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by `stream`.

If `stream` is a `GSocketConnection`, then the corresponding `GSocket` will be put into non-blocking mode.

The D-Bus connection will interact with `stream` from a worker thread. As a result, the caller should not interact with `stream` after this method has been called, except by calling `g_object_unref()` on it.

If `observer` is not `NULL` it may be used to control the authentication process.

This is a synchronous failable constructor. See `g_dbus_connection_new()` for the asynchronous version.

Available since: 2.26

#### Parameters

`stream`

  Type: `GIOStream`

  A `GIOStream`.

  The data is owned by the caller of the function.

`guid`

  Type: `const gchar*`

  The GUID to use if authenticating as a server or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`flags`

  Type: `GDBusConnectionFlags`

  Flags describing how to make the connection.

`observer`

  Type: `GDBusAuthObserver`

  A `GDBusAuthObserver` or `NULL`.

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

`cancellable`

  Type: `GCancellable`

  A `GCancellable` or `NULL`.

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

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the constructor if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GDBusConnection`

A `GDBusConnection` or `NULL` if `error` is set. Free with g_object_unref().

The caller of the function takes ownership of the data, and is responsible for freeing it.