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);
     }
 }
Exemple #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));
            }
        }
Exemple #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);
     }
 }
 internal extern static void CFStreamCreatePairWithPeerSocketSignature(/* CFAllocatorRef */ IntPtr allocator,
                                                                       /* CFSocketSignature* */ ref CFSocketSignature sig,
                                                                       /* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
Exemple #5
0
 internal static extern void CFStreamCreatePairWithPeerSocketSignature(/* CFAllocatorRef */ IntPtr allocator, 
     /* CFSocketSignature* */ ref CFSocketSignature sig,
     /* CFReadStreamRef* */ out IntPtr readStream, /* CFWriteStreamRef* */ out IntPtr writeStream);
Exemple #6
0
 extern static IntPtr CFSocketCreateConnectedToSocketSignature(IntPtr allocator, ref CFSocketSignature signature,
                                                               nuint /*CFOptionFlags*/ callBackTypes,
                                                               CFSocketCallBack callout,
                                                               IntPtr context, double timeout);
Exemple #7
0
 public CFSocket(AddressFamily family, SocketType type, ProtocolType proto, CFRunLoop loop)
     : this(CFSocketSignature.AddressFamilyToInt(family),
            CFSocketSignature.SocketTypeToInt(type),
            CFSocketSignature.ProtocolToInt(proto), loop)
 {
 }
Exemple #8
0
 static extern IntPtr CFSocketCreateConnectedToSocketSignature(IntPtr allocator, ref CFSocketSignature signature,
     nuint /*CFOptionFlags*/ callBackTypes,
     CFSocketCallBack callout,
     IntPtr context, double timeout);
Exemple #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);
            }
        }