当前位置: 首页>>代码示例>>C#>>正文


C# EndPoint.GetType方法代码示例

本文整理汇总了C#中System.Net.EndPoint.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# EndPoint.GetType方法的具体用法?C# EndPoint.GetType怎么用?C# EndPoint.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.EndPoint的用法示例。


在下文中一共展示了EndPoint.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectEndPoint

 public static int ConnectEndPoint(int hostId, EndPoint endPoint, int exceptionConnectionId, out byte error)
 {
   error = (byte) 0;
   byte[] numArray1 = new byte[4]{ (byte) 95, (byte) 36, (byte) 19, (byte) 246 };
   if (endPoint == null)
     throw new NullReferenceException("Null EndPoint provided");
   if (endPoint.GetType().FullName != "UnityEngine.XboxOne.XboxOneEndPoint" && endPoint.GetType().FullName != "UnityEngine.PS4.SceEndPoint")
     throw new ArgumentException("Endpoint of type XboxOneEndPoint or SceEndPoint  required");
   if (endPoint.GetType().FullName == "UnityEngine.XboxOne.XboxOneEndPoint")
   {
     EndPoint endPoint1 = endPoint;
     if (endPoint1.AddressFamily != AddressFamily.InterNetworkV6)
       throw new ArgumentException("XboxOneEndPoint has an invalid family");
     SocketAddress socketAddress = endPoint1.Serialize();
     if (socketAddress.Size != 14)
       throw new ArgumentException("XboxOneEndPoint has an invalid size");
     if ((int) socketAddress[0] != 0 || (int) socketAddress[1] != 0)
       throw new ArgumentException("XboxOneEndPoint has an invalid family signature");
     if ((int) socketAddress[2] != (int) numArray1[0] || (int) socketAddress[3] != (int) numArray1[1] || ((int) socketAddress[4] != (int) numArray1[2] || (int) socketAddress[5] != (int) numArray1[3]))
       throw new ArgumentException("XboxOneEndPoint has an invalid signature");
     byte[] numArray2 = new byte[8];
     for (int index = 0; index < numArray2.Length; ++index)
       numArray2[index] = socketAddress[6 + index];
     IntPtr num = new IntPtr(BitConverter.ToInt64(numArray2, 0));
     if (num == IntPtr.Zero)
       throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
     byte[] destination = new byte[2];
     Marshal.Copy(num, destination, 0, destination.Length);
     if (((int) destination[1] << 8) + (int) destination[0] != 23)
       throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
     return NetworkTransport.Internal_ConnectEndPoint(hostId, num, 128, exceptionConnectionId, out error);
   }
   SocketAddress socketAddress1 = endPoint.Serialize();
   if (socketAddress1.Size != 16)
     throw new ArgumentException("EndPoint has an invalid size");
   if ((int) socketAddress1[0] != socketAddress1.Size)
     throw new ArgumentException("EndPoint has an invalid size value");
   if ((int) socketAddress1[1] != 2)
     throw new ArgumentException("EndPoint has an invalid family value");
   byte[] source = new byte[16];
   for (int index = 0; index < source.Length; ++index)
     source[index] = socketAddress1[index];
   IntPtr num1 = Marshal.AllocHGlobal(source.Length);
   Marshal.Copy(source, 0, num1, source.Length);
   int num2 = NetworkTransport.Internal_ConnectEndPoint(hostId, num1, 16, exceptionConnectionId, out error);
   Marshal.FreeHGlobal(num1);
   return num2;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:48,代码来源:NetworkTransport.cs

示例2: DoesEndPointUsePlatformProtocols

 internal static bool DoesEndPointUsePlatformProtocols(EndPoint endPoint)
 {
   if (endPoint.GetType().FullName == "UnityEngine.PS4.SceEndPoint")
   {
     SocketAddress socketAddress = endPoint.Serialize();
     if ((int) socketAddress[8] != 0 || (int) socketAddress[9] != 0)
       return true;
   }
   return false;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:10,代码来源:NetworkTransport.cs

示例3: CheckCacheRemote

        //
        // socketAddress must always be the result of remoteEP.Serialize()
        //
        private void CheckCacheRemote(SocketAddress socketAddress, EndPoint remoteEP, bool isOverwrite) {
            // We remember the first peer we have communicated with
            if (m_PermittedRemoteAddress != null && m_PermittedRemoteAddress.Equals(socketAddress)) {
                return;
            }
            //
            // for now SocketPermission supports only IPEndPoint
            //
            if (remoteEP.GetType()==typeof(IPEndPoint)) {
                //
                // cast the EndPoint to IPEndPoint
                //
                IPEndPoint remoteIPEndPoint = (IPEndPoint)remoteEP;
                //
                // create the permissions the user would need for the call
                //
                SocketPermission socketPermission
                    = new SocketPermission(
                        NetworkAccess.Connect,
                        Transport,
                        remoteIPEndPoint.Address.ToString(),
                        remoteIPEndPoint.Port);
                //
                // demand for them
                //
                socketPermission.Demand();
            }
            else {
                //
                // for V1 we will demand permission to run UnmanagedCode for
                // an EndPoint that is not an IPEndPoint until we figure out how these fit
                // into the whole picture of SocketPermission
                //

                (new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Demand();
            }
            //cache only the first peer we communicated with
            if (m_PermittedRemoteAddress == null || isOverwrite) {
                m_PermittedRemoteAddress = socketAddress;
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:44,代码来源:socket.cs

示例4: Register

        public static LocalAddress Register(IChannel channel, LocalAddress oldLocalAddress, EndPoint localAddress)
        {
            if (oldLocalAddress != null)
                throw new HeliosException("already bound");

            if (!(localAddress is LocalAddress))
            {
                throw new HeliosException($"Unsupported address type {localAddress.GetType()}");
            }

            var addr = (LocalAddress) localAddress;
            if (LocalAddress.Any.Equals(addr))
            {
                addr = new LocalAddress(channel);
            }

            if (BoundChannels.ContainsKey(addr))
                throw new HeliosException($"address {addr} is already in use ");

            var boundChannel = BoundChannels.GetOrAdd(addr, channel);
            return addr;
        }
开发者ID:helios-io,项目名称:helios,代码行数:22,代码来源:LocalChannelRegistry.cs

示例5: ReceiveFrom

        /// <include file='doc\Socket.uex' path='docs/doc[@for="Socket.ReceiveFrom"]/*' />
        /// <devdoc>
        ///    <para>Receives a datagram into a specific location in the data buffer and stores
        ///       the end point.</para>
        /// </devdoc>
        public int ReceiveFrom(byte[] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP) {
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            if (buffer==null) {
                throw new ArgumentNullException("buffer");
            }
            if (remoteEP==null) {
                throw new ArgumentNullException("remoteEP");
            }
            if (offset<0 || offset>buffer.Length) {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (size<0 || size>buffer.Length-offset) {
                throw new ArgumentOutOfRangeException("size");
            }

            ValidateBlockingMode();

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::ReceiveFrom() remoteEP:" + remoteEP.ToString());

            EndPoint endPointSnapshot = remoteEP;
            if (remoteEP.GetType()==typeof(IPEndPoint)) {
                endPointSnapshot = new IPEndPoint(((IPEndPoint)remoteEP).Address, ((IPEndPoint)remoteEP).Port);
            }
            SocketAddress socketAddressOriginal = endPointSnapshot.Serialize();
            SocketAddress socketAddress = endPointSnapshot.Serialize();

            // This will check the permissions for connect.
            // We need this because remoteEP may differ from one used in Connect or
            // there was no Connect called.
            CheckCacheRemote(socketAddress, endPointSnapshot, false);

            GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            IntPtr pinnedBuffer = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, offset);

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.recvfrom(
                    m_Handle,
                    pinnedBuffer,
                    size,
                    socketFlags,
                    socketAddress.m_Buffer,
                    ref socketAddress.m_Size );

            gcHandle.Free();

            if (!socketAddressOriginal.Equals(socketAddress)) {
                try {
                    remoteEP = endPointSnapshot.Create(socketAddress);
                }
                catch {
                }
                if (m_RightEndPoint==null) {
                    //
                    // save a copy of the EndPoint so we can use it for Create()
                    //
                    m_RightEndPoint = endPointSnapshot;
                }
            }


            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketErrors.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError();
                throw socketException;
            }

            return errorCode;
        }
开发者ID:ArildF,项目名称:masters,代码行数:84,代码来源:socket.cs

示例6: SendTo

        /// <include file='doc\Socket.uex' path='docs/doc[@for="Socket.SendTo"]/*' />
        /// <devdoc>
        ///    <para>Sends data to a specific end point, starting at the indicated location in the
        ///       data.</para>
        /// </devdoc>
        public int SendTo(byte[] buffer, int offset, int size, SocketFlags socketFlags, EndPoint remoteEP) {
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            if (buffer==null) {
                throw new ArgumentNullException("buffer");
            }
            if (remoteEP==null) {
                throw new ArgumentNullException("remoteEP");
            }
            if (offset<0 || offset>buffer.Length) {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (size<0 || size>buffer.Length-offset) {
                throw new ArgumentOutOfRangeException("size");
            }

            ValidateBlockingMode();

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::SendTo() size:" + size.ToString() + " remoteEP:" + remoteEP.ToString());

            //
            // ask the EndPoint to generate a SocketAddress that we
            // can pass down to winsock
            //
            EndPoint endPointSnapshot = remoteEP;
            if (remoteEP.GetType()==typeof(IPEndPoint)) {
                endPointSnapshot = new IPEndPoint(((IPEndPoint)remoteEP).Address, ((IPEndPoint)remoteEP).Port);
            }
            SocketAddress socketAddress = endPointSnapshot.Serialize();

            //That will check ConnectPermission for remoteEP
            CheckCacheRemote(socketAddress, endPointSnapshot, false);

            GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            IntPtr pinnedBuffer = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, offset);

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.sendto(
                    m_Handle,
                    pinnedBuffer,
                    size,
                    socketFlags,
                    socketAddress.m_Buffer,
                    socketAddress.m_Size );

            gcHandle.Free();

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketErrors.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError();
                throw socketException;
            }

            if (m_RightEndPoint==null) {
                //
                // save a copy of the EndPoint so we can use it for Create()
                //
                m_RightEndPoint = endPointSnapshot;
            }


            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::SendTo() returning errorCode:" + errorCode.ToString());

            return errorCode;
        }
开发者ID:ArildF,项目名称:masters,代码行数:80,代码来源:socket.cs

示例7: Connect

        /// <include file='doc\Socket.uex' path='docs/doc[@for="Socket.Connect"]/*' />
        /// <devdoc>
        ///    <para>Establishes a connection to a remote system.</para>
        /// </devdoc>
        public void Connect(EndPoint remoteEP) {
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            if (remoteEP==null) {
                throw new ArgumentNullException("remoteEP");
            }
            ValidateBlockingMode();

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::Connect() remoteEP:" + remoteEP.ToString());

            //
            // ask the EndPoint to generate a SocketAddress that we
            // can pass down to winsock
            //
            EndPoint endPointSnapshot = remoteEP;
            if (remoteEP.GetType()==typeof(IPEndPoint)) {
                endPointSnapshot = new IPEndPoint(((IPEndPoint)remoteEP).Address, ((IPEndPoint)remoteEP).Port);
            }
            SocketAddress socketAddress = endPointSnapshot.Serialize();

            //This will check the permissions for connect
            CheckCacheRemote(socketAddress, endPointSnapshot, true);

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.connect(
                    m_Handle,
                    socketAddress.m_Buffer,
                    socketAddress.m_Size );

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode!=SocketErrors.Success) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError();
                throw socketException;
            }

            if (m_RightEndPoint==null) {
                //
                // save a copy of the EndPoint so we can use it for Create()
                //
                m_RightEndPoint = endPointSnapshot;
            }

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::Connect() now connected to:" + endPointSnapshot.ToString());

            //
            // update state and performance counter
            //
            SetToConnected();
        }
开发者ID:ArildF,项目名称:masters,代码行数:63,代码来源:socket.cs

示例8: BeginReceiveFrom

        /*++

        Routine Description:

           BeginReceiveFrom - Async implimentation of RecvFrom call,

           Called when we want to start an async receive.
           We kick off the receive, and if it completes synchronously we'll
           call the callback. Otherwise we'll return an IASyncResult, which
           the caller can use to wait on or retrieve the final status, as needed.

           Uses Winsock 2 overlapped I/O.

        Arguments:

           ReadBuffer - status line that we wish to parse
           Index - Offset into ReadBuffer to begin reading from
           Request - Size of Buffer to recv
           Flags - Additonal Flags that may be passed to the underlying winsock call
           remoteEP - EndPoint that are to receive from
           Callback - Delegate function that holds callback, called on completeion of I/O
           State - State used to track callback, set by caller, not required

        Return Value:

           IAsyncResult - Async result used to retreive result

        --*/

        /// <include file='doc\Socket.uex' path='docs/doc[@for="Socket.BeginReceiveFrom"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public IAsyncResult BeginReceiveFrom(byte[] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP, AsyncCallback callback, Object state) {
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            if (buffer==null) {
                throw new ArgumentNullException("buffer");
            }
            if (remoteEP==null) {
                throw new ArgumentNullException("remoteEP");
            }
            if (offset<0 || offset>buffer.Length) {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (size<0 || size>buffer.Length-offset) {
                throw new ArgumentOutOfRangeException("size");
            }

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::BeginReceiveFrom() size:" + size.ToString());

            //
            // Allocate the async result and the event we'll pass to the
            // thread pool.
            //
            OverlappedAsyncResult asyncResult =
                new OverlappedAsyncResult(
                    this,
                    state,
                    callback );

            //
            // Set up asyncResult for overlapped WSARecvFrom.
            // This call will use
            // completion ports on WinNT and Overlapped IO on Win9x.
            //
            EndPoint endPointSnapshot = remoteEP;
            if (remoteEP.GetType()==typeof(IPEndPoint)) {
                endPointSnapshot = new IPEndPoint(((IPEndPoint)remoteEP).Address, ((IPEndPoint)remoteEP).Port);
            }
            asyncResult.SetUnmanagedStructures(
                                          buffer,
                                          offset,
                                          size,
                                          socketFlags,
                                          endPointSnapshot,
                                          true // pin remoteEP
                                          );

            // save a copy of the original EndPoint in the asyncResult
            asyncResult.m_SocketAddressOriginal = endPointSnapshot.Serialize();

            // This will check the permissions for connect.
            CheckCacheRemote(asyncResult.m_SocketAddress, endPointSnapshot, false);

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.WSARecvFrom(
                    m_Handle,
                    ref asyncResult.m_WSABuffer,
                    1,
                    OverlappedAsyncResult.m_BytesTransferred,
                    ref asyncResult.m_Flags,
                    asyncResult.m_GCHandleSocketAddress.AddrOfPinnedObject(),
                    asyncResult.m_GCHandleSocketAddressSize.AddrOfPinnedObject(),
                    asyncResult.IntOverlapped,
                    IntPtr.Zero );
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:socket.cs

示例9: ConnectEndPoint

 public static int ConnectEndPoint(int hostId, EndPoint endPoint, int exceptionConnectionId, out byte error)
 {
     error = 0;
     byte[] buffer = new byte[] { 0x5f, 0x24, 0x13, 0xf6 };
     if (endPoint == null)
     {
         throw new NullReferenceException("Null EndPoint provided");
     }
     if (((endPoint.GetType().FullName != "UnityEngine.XboxOne.XboxOneEndPoint") && (endPoint.GetType().FullName != "UnityEngine.PS4.SceEndPoint")) && (endPoint.GetType().FullName != "UnityEngine.PSVita.SceEndPoint"))
     {
         throw new ArgumentException("Endpoint of type XboxOneEndPoint or SceEndPoint  required");
     }
     if (endPoint.GetType().FullName == "UnityEngine.XboxOne.XboxOneEndPoint")
     {
         EndPoint point = endPoint;
         if (point.AddressFamily != AddressFamily.InterNetworkV6)
         {
             throw new ArgumentException("XboxOneEndPoint has an invalid family");
         }
         SocketAddress address = point.Serialize();
         if (address.Size != 14)
         {
             throw new ArgumentException("XboxOneEndPoint has an invalid size");
         }
         if ((address[0] != 0) || (address[1] != 0))
         {
             throw new ArgumentException("XboxOneEndPoint has an invalid family signature");
         }
         if (((address[2] != buffer[0]) || (address[3] != buffer[1])) || ((address[4] != buffer[2]) || (address[5] != buffer[3])))
         {
             throw new ArgumentException("XboxOneEndPoint has an invalid signature");
         }
         byte[] buffer2 = new byte[8];
         for (int j = 0; j < buffer2.Length; j++)
         {
             buffer2[j] = address[6 + j];
         }
         IntPtr ptr = new IntPtr(BitConverter.ToInt64(buffer2, 0));
         if (ptr == IntPtr.Zero)
         {
             throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
         }
         byte[] buffer3 = new byte[2];
         Marshal.Copy(ptr, buffer3, 0, buffer3.Length);
         AddressFamily family = (AddressFamily) ((buffer3[1] << 8) + buffer3[0]);
         if (family != AddressFamily.InterNetworkV6)
         {
             throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
         }
         return Internal_ConnectEndPoint(hostId, ptr, 0x80, exceptionConnectionId, out error);
     }
     SocketAddress address2 = endPoint.Serialize();
     if (address2.Size != 0x10)
     {
         throw new ArgumentException("EndPoint has an invalid size");
     }
     if (address2[0] != address2.Size)
     {
         throw new ArgumentException("EndPoint has an invalid size value");
     }
     if (address2[1] != 2)
     {
         throw new ArgumentException("EndPoint has an invalid family value");
     }
     byte[] source = new byte[0x10];
     for (int i = 0; i < source.Length; i++)
     {
         source[i] = address2[i];
     }
     IntPtr destination = Marshal.AllocHGlobal(source.Length);
     Marshal.Copy(source, 0, destination, source.Length);
     int num4 = Internal_ConnectEndPoint(hostId, destination, 0x10, exceptionConnectionId, out error);
     Marshal.FreeHGlobal(destination);
     return num4;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:75,代码来源:NetworkTransport.cs

示例10: CanUseConnectEx

 private bool CanUseConnectEx(EndPoint remoteEP)
 {
     if (this.socketType != SocketType.Stream || this.m_RightEndPoint == null && !(remoteEP.GetType() == typeof (IPEndPoint)))
     return false;
       if (!Thread.CurrentThread.IsThreadPoolThread && !SettingsSectionInternal.Section.AlwaysUseCompletionPortsForConnect)
     return this.m_IsDisconnected;
       else
     return true;
 }
开发者ID:korifey,项目名称:hackathon-Ideaphone,代码行数:9,代码来源:Socket.cs

示例11: CanUseConnectEx

 private bool CanUseConnectEx(EndPoint remoteEP)
 {
     return (_socketType == SocketType.Stream) &&
         (_rightEndPoint != null || remoteEP.GetType() == typeof(IPEndPoint));
 }
开发者ID:charygao,项目名称:corefx,代码行数:5,代码来源:Socket.cs

示例12: Connect

 public void Connect(EndPoint secureTunnelEndPoint)
 {
     this.PrepareForConnect();
       if (LogFilter.logDebug)
     Debug.Log((object) "Client Connect to remoteSockAddr");
       if (secureTunnelEndPoint == null)
       {
     if (LogFilter.logError)
       Debug.LogError((object) "Connect failed: null endpoint passed in");
     this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
       }
       else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
       {
     if (LogFilter.logError)
       Debug.LogError((object) "Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
     this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
       }
       else
       {
     string fullName = secureTunnelEndPoint.GetType().FullName;
     if (fullName == "System.Net.IPEndPoint")
     {
       IPEndPoint ipEndPoint = (IPEndPoint) secureTunnelEndPoint;
       this.Connect(ipEndPoint.Address.ToString(), ipEndPoint.Port);
     }
     else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint")
     {
       if (LogFilter.logError)
     Debug.LogError((object) "Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint)");
       this.m_AsyncConnect = NetworkClient.ConnectState.Failed;
     }
     else
     {
       byte error = (byte) 0;
       this.m_RemoteEndPoint = secureTunnelEndPoint;
       this.m_AsyncConnect = NetworkClient.ConnectState.Connecting;
       try
       {
     this.m_ClientConnectionId = NetworkTransport.ConnectEndPoint(this.m_ClientId, this.m_RemoteEndPoint, 0, out error);
       }
       catch (Exception ex)
       {
     Debug.LogError((object) ("Connect failed: Exception when trying to connect to EndPoint: " + ex.ToString()));
       }
       if (this.m_ClientConnectionId == 0 && LogFilter.logError)
     Debug.LogError((object) ("Connect failed: Unable to connect to EndPoint (" + (object) error + ")"));
       this.m_Connection = new NetworkConnection();
       this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_hostTopology);
     }
       }
 }
开发者ID:Kitabalef,项目名称:Unet-Decompiles,代码行数:51,代码来源:NetworkClient.cs

示例13: ConnectEndPoint

 public static int ConnectEndPoint(int hostId, EndPoint xboxOneEndPoint, int exceptionConnectionId, out byte error)
 {
     error = 0;
     byte[] buffer = new byte[] { 0x5f, 0x24, 0x13, 0xf6 };
     if (xboxOneEndPoint == null)
     {
         throw new NullReferenceException("Null EndPoint provided");
     }
     if (xboxOneEndPoint.GetType().FullName != "UnityEngine.XboxOne.XboxOneEndPoint")
     {
         throw new ArgumentException("Endpoint of type XboxOneEndPoint required");
     }
     if (xboxOneEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
     {
         throw new ArgumentException("XboxOneEndPoint has an invalid family");
     }
     SocketAddress address = xboxOneEndPoint.Serialize();
     if (address.Size != 14)
     {
         throw new ArgumentException("XboxOneEndPoint has an invalid size");
     }
     if ((address[0] != 0) || (address[1] != 0))
     {
         throw new ArgumentException("XboxOneEndPoint has an invalid family signature");
     }
     if (((address[2] != buffer[0]) || (address[3] != buffer[1])) || ((address[4] != buffer[2]) || (address[5] != buffer[3])))
     {
         throw new ArgumentException("XboxOneEndPoint has an invalid signature");
     }
     byte[] buffer2 = new byte[8];
     for (int i = 0; i < buffer2.Length; i++)
     {
         buffer2[i] = address[6 + i];
     }
     IntPtr source = new IntPtr(BitConverter.ToInt64(buffer2, 0));
     if (source == IntPtr.Zero)
     {
         throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
     }
     byte[] destination = new byte[2];
     Marshal.Copy(source, destination, 0, destination.Length);
     AddressFamily family = (AddressFamily) ((destination[1] << 8) + destination[0]);
     if (family != AddressFamily.InterNetworkV6)
     {
         throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
     }
     return Internal_ConnectEndPoint(hostId, source, 0x80, exceptionConnectionId, out error);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:48,代码来源:NetworkTransport.cs

示例14: Connect

 public void Connect(EndPoint secureTunnelEndPoint)
 {
     bool usePlatformSpecificProtocols = NetworkTransport.DoesEndPointUsePlatformProtocols(secureTunnelEndPoint);
     this.PrepareForConnect(usePlatformSpecificProtocols);
     if (LogFilter.logDebug)
     {
         Debug.Log("Client Connect to remoteSockAddr");
     }
     if (secureTunnelEndPoint == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("Connect failed: null endpoint passed in");
         }
         this.m_AsyncConnect = ConnectState.Failed;
     }
     else if ((secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork) && (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6))
     {
         if (LogFilter.logError)
         {
             Debug.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
         }
         this.m_AsyncConnect = ConnectState.Failed;
     }
     else
     {
         string fullName = secureTunnelEndPoint.GetType().FullName;
         if (fullName == "System.Net.IPEndPoint")
         {
             IPEndPoint point = (IPEndPoint) secureTunnelEndPoint;
             this.Connect(point.Address.ToString(), point.Port);
         }
         else if (((fullName != "UnityEngine.XboxOne.XboxOneEndPoint") && (fullName != "UnityEngine.PS4.SceEndPoint")) && (fullName != "UnityEngine.PSVita.SceEndPoint"))
         {
             if (LogFilter.logError)
             {
                 Debug.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
             }
             this.m_AsyncConnect = ConnectState.Failed;
         }
         else
         {
             byte error = 0;
             this.m_RemoteEndPoint = secureTunnelEndPoint;
             this.m_AsyncConnect = ConnectState.Connecting;
             try
             {
                 this.m_ClientConnectionId = NetworkTransport.ConnectEndPoint(this.m_ClientId, this.m_RemoteEndPoint, 0, out error);
             }
             catch (Exception exception)
             {
                 if (LogFilter.logError)
                 {
                     Debug.LogError("Connect failed: Exception when trying to connect to EndPoint: " + exception);
                 }
                 this.m_AsyncConnect = ConnectState.Failed;
                 return;
             }
             if (this.m_ClientConnectionId == 0)
             {
                 if (LogFilter.logError)
                 {
                     Debug.LogError("Connect failed: Unable to connect to EndPoint (" + error + ")");
                 }
                 this.m_AsyncConnect = ConnectState.Failed;
             }
             else
             {
                 this.m_Connection = (NetworkConnection) Activator.CreateInstance(this.m_NetworkConnectionClass);
                 this.m_Connection.SetHandlers(this.m_MessageHandlers);
                 this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_HostTopology);
             }
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:75,代码来源:NetworkClient.cs

示例15: CanUseConnectEx

        // Begin ConnectEx is only supported for connection oriented protocols
        // for now this is only supported on win32 platforms.  We need to fix this
        // when the getdelegatefrom function methods are available on 64bit.
        // to use this, the endpoint must either be an IP endpoint, or the
        // socket must already be bound.
        private bool CanUseConnectEx(EndPoint remoteEP)
        {
#if !FEATURE_PAL
            return socketType == SocketType.Stream &&
                (m_RightEndPoint != null || remoteEP.GetType() == typeof(IPEndPoint)) &&
                (Thread.CurrentThread.IsThreadPoolThread || SettingsSectionInternal.Section.AlwaysUseCompletionPortsForConnect || m_IsDisconnected);
#else
            return false;
#endif
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:15,代码来源:Socket.cs


注:本文中的System.Net.EndPoint.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。