CFSocket(int family, int type, int proto, CFRunLoop loop) { var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.ConnectCallBack; gch = GCHandle.Alloc(this); var ctx = new CFStreamClientContext(); ctx.Info = GCHandle.ToIntPtr(gch); var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CFStreamClientContext))); try { Marshal.StructureToPtr(ctx, ptr, false); handle = CFSocketCreate( IntPtr.Zero, family, type, proto, (nuint)(ulong)cbTypes, OnCallback, ptr); } finally { Marshal.FreeHGlobal(ptr); } if (handle == IntPtr.Zero) { throw new CFSocketException(CFSocketError.Error); } gch = GCHandle.Alloc(this); var source = new CFRunLoopSource(CFSocketCreateRunLoopSource(IntPtr.Zero, handle, 0)); loop.AddSource(source, CFRunLoop.ModeDefault); }
internal CFSocket(CFSocketNativeHandle sock) { var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.WriteCallBack; gch = GCHandle.Alloc(this); var ctx = new CFStreamClientContext(); ctx.Info = GCHandle.ToIntPtr(gch); var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CFStreamClientContext))); try { Marshal.StructureToPtr(ctx, ptr, false); handle = CFSocketCreateWithNative( IntPtr.Zero, sock, (nuint)(ulong)cbTypes, OnCallback, ptr); } finally { Marshal.FreeHGlobal(ptr); } if (handle == IntPtr.Zero) { throw new CFSocketException(CFSocketError.Error); } var source = new CFRunLoopSource(CFSocketCreateRunLoopSource(IntPtr.Zero, handle, 0)); var loop = CFRunLoop.Current; loop.AddSource(source, CFRunLoop.ModeDefault); }
CFSocket(IntPtr handle) { this.handle = handle; gch = GCHandle.Alloc(this); var source = new CFRunLoopSource(CFSocketCreateRunLoopSource(IntPtr.Zero, handle, 0)); var loop = CFRunLoop.Current; loop.AddSource(source, CFRunLoop.ModeDefault); }
public bool ContainsSource(CFRunLoopSource source, NSString mode) { if (source == null) { throw new ArgumentNullException("source"); } if (mode == null) { throw new ArgumentNullException("mode"); } return(CFRunLoopContainsSource(handle, source.Handle, mode.Handle)); }
public void AddSource(CFRunLoopSource source, NSString mode) { if (source == null) { throw new ArgumentNullException("source"); } if (mode == null) { throw new ArgumentNullException("mode"); } CFRunLoopAddSource(handle, source.Handle, mode.Handle); }
public bool RemoveSource(CFRunLoopSource source, NSString mode) #endif { if (source == null) { throw new ArgumentNullException("source"); } if (mode == null) { throw new ArgumentNullException("mode"); } CFRunLoopRemoveSource(handle, source.Handle, mode.Handle); #if !XAMCORE_2_0 return(true); #endif }
public void RemoveSource(CFRunLoopSource source, NSString mode)
CFSocket(int family, int type, int proto, CFRunLoop loop) { var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.ConnectCallBack; gch = GCHandle.Alloc (this); var ctx = new CFStreamClientContext (); ctx.Info = GCHandle.ToIntPtr (gch); var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(CFStreamClientContext))); try { Marshal.StructureToPtr (ctx, ptr, false); handle = CFSocketCreate ( IntPtr.Zero, family, type, proto, (nuint) (ulong) cbTypes, OnCallback, ptr); } finally { Marshal.FreeHGlobal (ptr); } if (handle == IntPtr.Zero) throw new CFSocketException (CFSocketError.Error); gch = GCHandle.Alloc (this); var source = new CFRunLoopSource (CFSocketCreateRunLoopSource (IntPtr.Zero, handle, 0)); loop.AddSource (source, CFRunLoop.ModeDefault); }
CFSocket(IntPtr handle) { this.handle = handle; gch = GCHandle.Alloc (this); var source = new CFRunLoopSource (CFSocketCreateRunLoopSource (IntPtr.Zero, handle, 0)); var loop = CFRunLoop.Current; loop.AddSource (source, CFRunLoop.ModeDefault); }
internal CFSocket(CFSocketNativeHandle sock) { var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.WriteCallBack; gch = GCHandle.Alloc (this); var ctx = new CFStreamClientContext (); ctx.Info = GCHandle.ToIntPtr (gch); var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(CFStreamClientContext))); try { Marshal.StructureToPtr (ctx, ptr, false); handle = CFSocketCreateWithNative ( IntPtr.Zero, sock, (nuint) (ulong) cbTypes, OnCallback, ptr); } finally { Marshal.FreeHGlobal (ptr); } if (handle == IntPtr.Zero) throw new CFSocketException (CFSocketError.Error); var source = new CFRunLoopSource (CFSocketCreateRunLoopSource (IntPtr.Zero, handle, 0)); var loop = CFRunLoop.Current; loop.AddSource (source, CFRunLoop.ModeDefault); }
public bool RemoveSource (CFRunLoopSource source, NSString mode) #endif { if (source == null) throw new ArgumentNullException ("source"); if (mode == null) throw new ArgumentNullException ("mode"); CFRunLoopRemoveSource (handle, source.Handle, mode.Handle); #if !XAMCORE_2_0 return true; #endif }
public void RemoveSource (CFRunLoopSource source, NSString mode)
public bool ContainsSource (CFRunLoopSource source, NSString mode) { if (source == null) throw new ArgumentNullException ("source"); if (mode == null) throw new ArgumentNullException ("mode"); return CFRunLoopContainsSource (handle, source.Handle, mode.Handle); }
public void AddSource (CFRunLoopSource source, NSString mode) { if (source == null) throw new ArgumentNullException ("source"); if (mode == null) throw new ArgumentNullException ("mode"); CFRunLoopAddSource (handle, source.Handle, mode.Handle); }