예제 #1
0
 public static void CreatePairWithPeerSocketSignature(AddressFamily family, SocketType type,
                                                      ProtocolType proto, IPEndPoint endpoint,
                                                      out CFReadStream readStream,
                                                      out CFWriteStream writeStream)
 {
     using (var address = new CFSocketAddress(endpoint)) {
         var    sig = new CFSocketSignature(family, type, proto, address);
         IntPtr read, write;
         CFStreamCreatePairWithPeerSocketSignature(IntPtr.Zero, ref sig, out read, out write);
         readStream  = new CFReadStream(read);
         writeStream = new CFWriteStream(write);
     }
 }
예제 #2
0
        public static CFSocket CreateConnectedToSocketSignature(AddressFamily family, SocketType type,
                                                                ProtocolType proto, IPEndPoint endpoint,
                                                                double timeout)
        {
            var cbTypes = CFSocketCallBackType.ConnectCallBack | CFSocketCallBackType.DataCallBack;

            using (var address = new CFSocketAddress(endpoint)) {
                var sig    = new CFSocketSignature(family, type, proto, address);
                var handle = CFSocketCreateConnectedToSocketSignature(
                    IntPtr.Zero, ref sig, (nuint)(ulong)cbTypes, OnCallback, IntPtr.Zero, timeout);
                if (handle == IntPtr.Zero)
                {
                    throw new CFSocketException(CFSocketError.Error);
                }

                return(new CFSocket(handle));
            }
        }
예제 #3
0
 public static void CreatePairWithPeerSocketSignature(AddressFamily family, SocketType type,
     ProtocolType proto, IPEndPoint endpoint,
     out NSInputStream readStream,
     out NSOutputStream writeStream)
 {
     using (var address = new CFSocketAddress (endpoint)) {
         var sig = new CFSocketSignature (family, type, proto, address);
         IntPtr read, write;
         CFStream.CFStreamCreatePairWithPeerSocketSignature (IntPtr.Zero, ref sig, out read, out write);
         AssignStreams (read, write, out readStream, out writeStream);
     }
 }
예제 #4
0
 internal extern static void CFStreamCreatePairWithPeerSocketSignature(/* CFAllocatorRef */ IntPtr allocator,
                                                                       /* CFSocketSignature* */ ref CFSocketSignature sig,
                                                                       /* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
예제 #5
0
 internal static extern void CFStreamCreatePairWithPeerSocketSignature(/* CFAllocatorRef */ IntPtr allocator, 
     /* CFSocketSignature* */ ref CFSocketSignature sig,
     /* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
예제 #6
0
 extern static IntPtr CFSocketCreateConnectedToSocketSignature(IntPtr allocator, ref CFSocketSignature signature,
                                                               nuint /*CFOptionFlags*/ callBackTypes,
                                                               CFSocketCallBack callout,
                                                               IntPtr context, double timeout);
예제 #7
0
 public CFSocket(AddressFamily family, SocketType type, ProtocolType proto, CFRunLoop loop)
     : this(CFSocketSignature.AddressFamilyToInt(family),
            CFSocketSignature.SocketTypeToInt(type),
            CFSocketSignature.ProtocolToInt(proto), loop)
 {
 }
예제 #8
0
 static extern IntPtr CFSocketCreateConnectedToSocketSignature(IntPtr allocator, ref CFSocketSignature signature,
     nuint /*CFOptionFlags*/ callBackTypes,
     CFSocketCallBack callout,
     IntPtr context, double timeout);
예제 #9
0
        public static CFSocket CreateConnectedToSocketSignature(AddressFamily family, SocketType type,
            ProtocolType proto, IPEndPoint endpoint,
            double timeout)
        {
            var cbTypes = CFSocketCallBackType.ConnectCallBack | CFSocketCallBackType.DataCallBack;
            using (var address = new CFSocketAddress (endpoint)) {
                var sig = new CFSocketSignature (family, type, proto, address);
                var handle = CFSocketCreateConnectedToSocketSignature (
                    IntPtr.Zero, ref sig, (nuint) (ulong) cbTypes, OnCallback, IntPtr.Zero, timeout);
                if (handle == IntPtr.Zero)
                    throw new CFSocketException (CFSocketError.Error);

                return new CFSocket (handle);
            }
        }