// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class SocketClient : GLib.Object {

		public SocketClient (IntPtr raw) : base(raw) {}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_new();
		static d_g_socket_client_new g_socket_client_new = FuncLoader.LoadFunction<d_g_socket_client_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_new"));

		public SocketClient () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (SocketClient)) {
				CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
				return;
			}
			Raw = g_socket_client_new();
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_client_get_family(IntPtr raw);
		static d_g_socket_client_get_family g_socket_client_get_family = FuncLoader.LoadFunction<d_g_socket_client_get_family>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_family"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_family(IntPtr raw, int family);
		static d_g_socket_client_set_family g_socket_client_set_family = FuncLoader.LoadFunction<d_g_socket_client_set_family>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_family"));

		[GLib.Property ("family")]
		public GLib.SocketFamily Family {
			get  {
				int raw_ret = g_socket_client_get_family(Handle);
				GLib.SocketFamily ret = (GLib.SocketFamily) raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_family(Handle, (int) value);
			}
		}

		[GLib.Property ("type")]
		public GLib.SocketType Type {
			get {
				GLib.Value val = GetProperty ("type");
				GLib.SocketType ret = (GLib.SocketType) (Enum) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value((Enum) value);
				SetProperty("type", val);
				val.Dispose ();
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_client_get_protocol(IntPtr raw);
		static d_g_socket_client_get_protocol g_socket_client_get_protocol = FuncLoader.LoadFunction<d_g_socket_client_get_protocol>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_protocol"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_protocol(IntPtr raw, int protocol);
		static d_g_socket_client_set_protocol g_socket_client_set_protocol = FuncLoader.LoadFunction<d_g_socket_client_set_protocol>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_protocol"));

		[GLib.Property ("protocol")]
		public GLib.SocketProtocol Protocol {
			get  {
				int raw_ret = g_socket_client_get_protocol(Handle);
				GLib.SocketProtocol ret = (GLib.SocketProtocol) raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_protocol(Handle, (int) value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_get_local_address(IntPtr raw);
		static d_g_socket_client_get_local_address g_socket_client_get_local_address = FuncLoader.LoadFunction<d_g_socket_client_get_local_address>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_local_address"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_local_address(IntPtr raw, IntPtr address);
		static d_g_socket_client_set_local_address g_socket_client_set_local_address = FuncLoader.LoadFunction<d_g_socket_client_set_local_address>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_local_address"));

		[GLib.Property ("local-address")]
		public GLib.SocketAddress LocalAddress {
			get  {
				IntPtr raw_ret = g_socket_client_get_local_address(Handle);
				GLib.SocketAddress ret = GLib.Object.GetObject(raw_ret) as GLib.SocketAddress;
				return ret;
			}
			set  {
				g_socket_client_set_local_address(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate uint d_g_socket_client_get_timeout(IntPtr raw);
		static d_g_socket_client_get_timeout g_socket_client_get_timeout = FuncLoader.LoadFunction<d_g_socket_client_get_timeout>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_timeout"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_timeout(IntPtr raw, uint timeout);
		static d_g_socket_client_set_timeout g_socket_client_set_timeout = FuncLoader.LoadFunction<d_g_socket_client_set_timeout>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_timeout"));

		[GLib.Property ("timeout")]
		public uint Timeout {
			get  {
				uint raw_ret = g_socket_client_get_timeout(Handle);
				uint ret = raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_timeout(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_socket_client_get_enable_proxy(IntPtr raw);
		static d_g_socket_client_get_enable_proxy g_socket_client_get_enable_proxy = FuncLoader.LoadFunction<d_g_socket_client_get_enable_proxy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_enable_proxy"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_enable_proxy(IntPtr raw, bool enable);
		static d_g_socket_client_set_enable_proxy g_socket_client_set_enable_proxy = FuncLoader.LoadFunction<d_g_socket_client_set_enable_proxy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_enable_proxy"));

		[GLib.Property ("enable-proxy")]
		public bool EnableProxy {
			get  {
				bool raw_ret = g_socket_client_get_enable_proxy(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_enable_proxy(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_socket_client_get_tls(IntPtr raw);
		static d_g_socket_client_get_tls g_socket_client_get_tls = FuncLoader.LoadFunction<d_g_socket_client_get_tls>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_tls"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_tls(IntPtr raw, bool tls);
		static d_g_socket_client_set_tls g_socket_client_set_tls = FuncLoader.LoadFunction<d_g_socket_client_set_tls>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_tls"));

		[GLib.Property ("tls")]
		public bool Tls {
			get  {
				bool raw_ret = g_socket_client_get_tls(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_tls(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_client_get_tls_validation_flags(IntPtr raw);
		static d_g_socket_client_get_tls_validation_flags g_socket_client_get_tls_validation_flags = FuncLoader.LoadFunction<d_g_socket_client_get_tls_validation_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_tls_validation_flags"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_tls_validation_flags(IntPtr raw, int flags);
		static d_g_socket_client_set_tls_validation_flags g_socket_client_set_tls_validation_flags = FuncLoader.LoadFunction<d_g_socket_client_set_tls_validation_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_tls_validation_flags"));

		[GLib.Property ("tls-validation-flags")]
		public GLib.TlsCertificateFlags TlsValidationFlags {
			get  {
				int raw_ret = g_socket_client_get_tls_validation_flags(Handle);
				GLib.TlsCertificateFlags ret = (GLib.TlsCertificateFlags) raw_ret;
				return ret;
			}
			set  {
				g_socket_client_set_tls_validation_flags(Handle, (int) value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_get_proxy_resolver(IntPtr raw);
		static d_g_socket_client_get_proxy_resolver g_socket_client_get_proxy_resolver = FuncLoader.LoadFunction<d_g_socket_client_get_proxy_resolver>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_proxy_resolver"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_proxy_resolver(IntPtr raw, IntPtr proxy_resolver);
		static d_g_socket_client_set_proxy_resolver g_socket_client_set_proxy_resolver = FuncLoader.LoadFunction<d_g_socket_client_set_proxy_resolver>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_proxy_resolver"));

		[GLib.Property ("proxy-resolver")]
		public GLib.IProxyResolver ProxyResolver {
			get  {
				IntPtr raw_ret = g_socket_client_get_proxy_resolver(Handle);
				GLib.IProxyResolver ret = GLib.ProxyResolverAdapter.GetObject (raw_ret, false);
				return ret;
			}
			set  {
				g_socket_client_set_proxy_resolver(Handle, value == null ? IntPtr.Zero : ((value is GLib.Object) ? (value as GLib.Object).Handle : (value as GLib.ProxyResolverAdapter).Handle));
			}
		}

		[GLib.Signal("event")]
		public event GLib.SocketEventHandler SocketEvent {
			add {
				this.AddSignalHandler ("event", value, typeof (GLib.SocketEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("event", value);
			}
		}

		static SocketEventNativeDelegate SocketEvent_cb_delegate;
		static SocketEventNativeDelegate SocketEventVMCallback {
			get {
				if (SocketEvent_cb_delegate == null)
					SocketEvent_cb_delegate = new SocketEventNativeDelegate (SocketEvent_cb);
				return SocketEvent_cb_delegate;
			}
		}

		static void OverrideSocketEvent (GLib.GType gtype)
		{
			OverrideSocketEvent (gtype, SocketEventVMCallback);
		}

		static void OverrideSocketEvent (GLib.GType gtype, SocketEventNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("event"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SocketEventNativeDelegate (IntPtr inst, int evnt, IntPtr connectable, IntPtr connection);

		static void SocketEvent_cb (IntPtr inst, int evnt, IntPtr connectable, IntPtr connection)
		{
			try {
				SocketClient __obj = GLib.Object.GetObject (inst, false) as SocketClient;
				__obj.OnSocketEvent ((GLib.SocketClientEvent) evnt, GLib.SocketConnectableAdapter.GetObject (connectable, false), GLib.Object.GetObject(connection) as GLib.IOStream);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketClient), ConnectionMethod="OverrideSocketEvent")]
		protected virtual void OnSocketEvent (GLib.SocketClientEvent evnt, GLib.ISocketConnectable connectable, GLib.IOStream connection)
		{
			InternalSocketEvent (evnt, connectable, connection);
		}

		private void InternalSocketEvent (GLib.SocketClientEvent evnt, GLib.ISocketConnectable connectable, GLib.IOStream connection)
		{
			SocketEventNativeDelegate unmanaged = class_abi.BaseOverride<SocketEventNativeDelegate>(this.LookupGType(), "event");
			if (unmanaged == null) return;

			unmanaged (this.Handle, (int) evnt, connectable == null ? IntPtr.Zero : ((connectable is GLib.Object) ? (connectable as GLib.Object).Handle : (connectable as GLib.SocketConnectableAdapter).Handle), connection == null ? IntPtr.Zero : connection.Handle);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("event"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // event
							, null
							, "_g_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved1
							, "event"
							, "_g_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved2
							, "_g_reserved1"
							, "_g_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved3
							, "_g_reserved2"
							, "_g_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved4
							, "_g_reserved3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_add_application_proxy(IntPtr raw, IntPtr protocol);
		static d_g_socket_client_add_application_proxy g_socket_client_add_application_proxy = FuncLoader.LoadFunction<d_g_socket_client_add_application_proxy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_add_application_proxy"));

		public void AddApplicationProxy(string protocol) {
			IntPtr native_protocol = GLib.Marshaller.StringToPtrGStrdup (protocol);
			g_socket_client_add_application_proxy(Handle, native_protocol);
			GLib.Marshaller.Free (native_protocol);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect(IntPtr raw, IntPtr connectable, IntPtr cancellable, out IntPtr error);
		static d_g_socket_client_connect g_socket_client_connect = FuncLoader.LoadFunction<d_g_socket_client_connect>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect"));

		public unsafe GLib.SocketConnection Connect(GLib.ISocketConnectable connectable, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect(Handle, connectable == null ? IntPtr.Zero : ((connectable is GLib.Object) ? (connectable as GLib.Object).Handle : (connectable as GLib.SocketConnectableAdapter).Handle), cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_connect_async(IntPtr raw, IntPtr connectable, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_socket_client_connect_async g_socket_client_connect_async = FuncLoader.LoadFunction<d_g_socket_client_connect_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_async"));

		public void ConnectAsync(GLib.ISocketConnectable connectable, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_socket_client_connect_async(Handle, connectable == null ? IntPtr.Zero : ((connectable is GLib.Object) ? (connectable as GLib.Object).Handle : (connectable as GLib.SocketConnectableAdapter).Handle), cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_socket_client_connect_finish g_socket_client_connect_finish = FuncLoader.LoadFunction<d_g_socket_client_connect_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_finish"));

		public unsafe GLib.SocketConnection ConnectFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_host(IntPtr raw, IntPtr host_and_port, ushort default_port, IntPtr cancellable, out IntPtr error);
		static d_g_socket_client_connect_to_host g_socket_client_connect_to_host = FuncLoader.LoadFunction<d_g_socket_client_connect_to_host>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_host"));

		public unsafe GLib.SocketConnection ConnectToHost(string host_and_port, ushort default_port, GLib.Cancellable cancellable) {
			IntPtr native_host_and_port = GLib.Marshaller.StringToPtrGStrdup (host_and_port);
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_host(Handle, native_host_and_port, default_port, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			GLib.Marshaller.Free (native_host_and_port);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_connect_to_host_async(IntPtr raw, IntPtr host_and_port, ushort default_port, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_socket_client_connect_to_host_async g_socket_client_connect_to_host_async = FuncLoader.LoadFunction<d_g_socket_client_connect_to_host_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_host_async"));

		public void ConnectToHostAsync(string host_and_port, ushort default_port, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_host_and_port = GLib.Marshaller.StringToPtrGStrdup (host_and_port);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_socket_client_connect_to_host_async(Handle, native_host_and_port, default_port, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (native_host_and_port);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_host_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_socket_client_connect_to_host_finish g_socket_client_connect_to_host_finish = FuncLoader.LoadFunction<d_g_socket_client_connect_to_host_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_host_finish"));

		public unsafe GLib.SocketConnection ConnectToHostFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_host_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_service(IntPtr raw, IntPtr domain, IntPtr service, IntPtr cancellable, out IntPtr error);
		static d_g_socket_client_connect_to_service g_socket_client_connect_to_service = FuncLoader.LoadFunction<d_g_socket_client_connect_to_service>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_service"));

		public unsafe GLib.SocketConnection ConnectToService(string domain, string service, GLib.Cancellable cancellable) {
			IntPtr native_domain = GLib.Marshaller.StringToPtrGStrdup (domain);
			IntPtr native_service = GLib.Marshaller.StringToPtrGStrdup (service);
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_service(Handle, native_domain, native_service, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			GLib.Marshaller.Free (native_domain);
			GLib.Marshaller.Free (native_service);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_connect_to_service_async(IntPtr raw, IntPtr domain, IntPtr service, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_socket_client_connect_to_service_async g_socket_client_connect_to_service_async = FuncLoader.LoadFunction<d_g_socket_client_connect_to_service_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_service_async"));

		public void ConnectToServiceAsync(string domain, string service, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_domain = GLib.Marshaller.StringToPtrGStrdup (domain);
			IntPtr native_service = GLib.Marshaller.StringToPtrGStrdup (service);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_socket_client_connect_to_service_async(Handle, native_domain, native_service, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (native_domain);
			GLib.Marshaller.Free (native_service);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_service_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_socket_client_connect_to_service_finish g_socket_client_connect_to_service_finish = FuncLoader.LoadFunction<d_g_socket_client_connect_to_service_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_service_finish"));

		public unsafe GLib.SocketConnection ConnectToServiceFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_service_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_uri(IntPtr raw, IntPtr uri, ushort default_port, IntPtr cancellable, out IntPtr error);
		static d_g_socket_client_connect_to_uri g_socket_client_connect_to_uri = FuncLoader.LoadFunction<d_g_socket_client_connect_to_uri>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_uri"));

		public unsafe GLib.SocketConnection ConnectToUri(string uri, ushort default_port, GLib.Cancellable cancellable) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_uri(Handle, native_uri, default_port, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_connect_to_uri_async(IntPtr raw, IntPtr uri, ushort default_port, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_socket_client_connect_to_uri_async g_socket_client_connect_to_uri_async = FuncLoader.LoadFunction<d_g_socket_client_connect_to_uri_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_uri_async"));

		public void ConnectToUriAsync(string uri, ushort default_port, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_socket_client_connect_to_uri_async(Handle, native_uri, default_port, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (native_uri);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_connect_to_uri_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_socket_client_connect_to_uri_finish g_socket_client_connect_to_uri_finish = FuncLoader.LoadFunction<d_g_socket_client_connect_to_uri_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_connect_to_uri_finish"));

		public unsafe GLib.SocketConnection ConnectToUriFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_socket_client_connect_to_uri_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			GLib.SocketConnection ret = GLib.Object.GetObject(raw_ret) as GLib.SocketConnection;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_client_get_socket_type(IntPtr raw);
		static d_g_socket_client_get_socket_type g_socket_client_get_socket_type = FuncLoader.LoadFunction<d_g_socket_client_get_socket_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_socket_type"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_client_set_socket_type(IntPtr raw, int type);
		static d_g_socket_client_set_socket_type g_socket_client_set_socket_type = FuncLoader.LoadFunction<d_g_socket_client_set_socket_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_set_socket_type"));

		public GLib.SocketType SocketType { 
			get {
				int raw_ret = g_socket_client_get_socket_type(Handle);
				GLib.SocketType ret = (GLib.SocketType) raw_ret;
				return ret;
			}
			set {
				g_socket_client_set_socket_type(Handle, (int) value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_client_get_type();
		static d_g_socket_client_get_type g_socket_client_get_type = FuncLoader.LoadFunction<d_g_socket_client_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_client_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = g_socket_client_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
