uv_ip6_addr() private method

private uv_ip6_addr ( string ip, int port, sockaddr_in6 &address ) : int
ip string
port int
address sockaddr_in6
return int
示例#1
0
        public void Connect(IPAddress ipAddress, int port, Action <Exception> callback)
        {
            Ensure.ArgumentNotNull(ipAddress, "ipAddress");
            Ensure.ArgumentNotNull(callback, "callback");

            ConnectRequest cpr    = new ConnectRequest();
            Tcp            socket = this;

            cpr.Callback = (status, cpr2) => {
                if (status == 0)
                {
                    callback(null);
                }
                else
                {
                    callback(Ensure.Success(Loop));
                }
            };

            int r;

            if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                r = uv_tcp_connect(cpr.Handle, socket.NativeHandle, UV.uv_ip4_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
            }
            else
            {
                r = uv_tcp_connect6(cpr.Handle, socket.NativeHandle, UV.uv_ip6_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
            }
            Ensure.Success(r, Loop);
        }
示例#2
0
        public void Send(IPAddress ipAddress, int port, byte[] data, int index, int count, Action <bool> callback)
        {
            Ensure.ArgumentNotNull(ipAddress, "ipAddress");
            Ensure.AddressFamily(ipAddress);
            Ensure.ArgumentNotNull(data, "data");

            GCHandle             datagchandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            CallbackPermaRequest cpr          = new CallbackPermaRequest(RequestType.UV_UDP_SEND);

            cpr.Callback += (status, cpr2) => {
                datagchandle.Free();
                if (callback != null)
                {
                    callback(status == 0);
                }
            };

            var ptr = (IntPtr)(datagchandle.AddrOfPinnedObject().ToInt64() + index);

            int r;

            if (UV.isUnix)
            {
                UnixBufferStruct[] buf = new UnixBufferStruct[1];
                buf[0] = new UnixBufferStruct(ptr, count);

                if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    r = uv_udp_send_unix(cpr.Handle, NativeHandle, buf, 1, UV.uv_ip4_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
                }
                else
                {
                    r = uv_udp_send6_unix(cpr.Handle, NativeHandle, buf, 1, UV.uv_ip6_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
                }
            }
            else
            {
                WindowsBufferStruct[] buf = new WindowsBufferStruct[1];
                buf[0] = new WindowsBufferStruct(ptr, count);

                if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    r = uv_udp_send_win(cpr.Handle, NativeHandle, buf, 1, UV.uv_ip4_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
                }
                else
                {
                    r = uv_udp_send6_win(cpr.Handle, NativeHandle, buf, 1, UV.uv_ip6_addr(ipAddress.ToString(), port), CallbackPermaRequest.StaticEnd);
                }
            }
            Ensure.Success(r, Loop);
        }
示例#3
0
        public void Bind(IPAddress ipAddress, int port)
        {
            Ensure.ArgumentNotNull(ipAddress, "ipAddress");
            int r;

            if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                r = uv_tcp_bind(handle, UV.uv_ip4_addr(ipAddress.ToString(), port));
            }
            else
            {
                r = uv_tcp_bind6(handle, UV.uv_ip6_addr(ipAddress.ToString(), port));
            }
            Ensure.Success(r, Loop);
        }
示例#4
0
        void Bind(IPAddress ipAddress, int port, short flags)
        {
            Ensure.AddressFamily(ipAddress);

            dualstack = (flags & (short)uv_udp_flags.UV_UDP_IPV6ONLY) == 0 &&
                        ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6;

            int r;

            if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                r = uv_udp_bind(NativeHandle, UV.uv_ip4_addr(ipAddress.ToString(), port), 0);
            }
            else
            {
                r = uv_udp_bind6(NativeHandle, UV.uv_ip6_addr(ipAddress.ToString(), port), 0);
            }
            Ensure.Success(r, Loop);
        }