예제 #1
0
		internal AsyncConnectRegistration(UDTSocket socket, IPEndPoint endPoint, AsyncCallback paramCallBack, object paramState)
		{
			Socket = socket;
			EndPoint = endPoint;
			ParamCallBack = paramCallBack;
			ParamState = paramState;
		}
예제 #2
0
 internal AsyncConnectRegistration(UDTSocket socket, IPEndPoint endPoint, AsyncCallback paramCallBack, object paramState)
 {
     Socket        = socket;
     EndPoint      = endPoint;
     ParamCallBack = paramCallBack;
     ParamState    = paramState;
 }
예제 #3
0
 public UDTAsyncResult(int size, object stateObject, UDTSocket socket, int overlappedIoHanlde)
 {
     _size               = size;
     _stateObject        = stateObject;
     _socket             = socket;
     _overlappedIoHanlde = overlappedIoHanlde;
 }
예제 #4
0
 internal AsyncSendRegistration(UDTSocket socket, byte[] paramBuffer, int paramOffset, int paramSize, SocketFlags paramSocketFlags, AsyncCallback paramCallBack, object paramState)
 {
     Socket           = socket;
     ParamCallBack    = paramCallBack;
     ParamState       = paramState;
     ParamBuffer      = paramBuffer;
     ParamOffset      = paramOffset;
     ParamSize        = paramSize;
     ParamSocketFlags = paramSocketFlags;
 }
예제 #5
0
        public void Execute()
        {
            try
            {
                UDTSocket acceptedSocket = Socket.Accept();

                ParamCallBack(new UDTAsyncResult(0, ParamState, acceptedSocket, 0));
            }

            catch (UDTSocketException e)
            {
                // A blocking operation was interrupted
                // by a call to WSACancelBlockingCall.
                // (By example when "close" is called on the socket)
                if (e.ErrorCode == 10004)
                {
                    return;
                }
            }
        }
예제 #6
0
		internal AsyncAcceptRegistration(UDTSocket socket, AsyncCallback paramCallBack, object paramState)
		{
			Socket = socket;
			ParamCallBack = paramCallBack;
			ParamState = paramState;
		}
예제 #7
0
		internal AsyncSendRegistration(UDTSocket socket, byte[] paramBuffer, int paramOffset, int paramSize, SocketFlags paramSocketFlags, AsyncCallback paramCallBack, object paramState)
		{
			Socket = socket;
			ParamCallBack = paramCallBack;
			ParamState = paramState;
			ParamBuffer = paramBuffer;
			ParamOffset = paramOffset;
			ParamSize = paramSize;
			ParamSocketFlags = paramSocketFlags;
		}
예제 #8
0
 internal AsyncAcceptRegistration(UDTSocket socket, AsyncCallback paramCallBack, object paramState)
 {
     Socket        = socket;
     ParamCallBack = paramCallBack;
     ParamState    = paramState;
 }
예제 #9
0
		public UDTSocket Accept()
		{
#if UDT_FULLTCP
            System.Net.Sockets.Socket newSocket = _tcpSocket.Accept();
            UDTSocket newUDTSocket = new UDTSocket(newSocket);

            // Tracing
            UDTTrace("UDTSocket[" + _tcpSocket.Handle + ", new:" + newSocket.Handle + "]-Accept:" + newSocket.RemoteEndPoint.ToString());

            return newUDTSocket;
#else
			//---- UDT
			EndPoint localEP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
			SocketAddress address = ((IPEndPoint)localEP).Serialize();

			byte[] addressBuffer = new byte[address.Size];

			for (int index = 0; index < address.Size; index++)
				addressBuffer[index] = address[index];

			//---- Accept
			int size = 0;
			int newHandle = API_Accept(_handle, addressBuffer, out size);

			if (UDT_INVALID_SOCK == newHandle) // UDT::INVALID_SOCK
			{
				throw new UDTSocketException(API_GetLastErrorCode(),
											API_GetLastErrorMessage());
			}

			//---- Get the IP+port of the peer socket (RemoteEndPoint)
			for (int index = 0; index < address.Size; index++)
				address[index] = addressBuffer[index];

			IPEndPoint remoteEndPoint;

			if (address.Family == AddressFamily.InterNetwork)
				remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);

			else
				remoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
			remoteEndPoint = (IPEndPoint)(remoteEndPoint.Create(address));

			//---- Get the IP+port of the socket (LocalEndPoint)
			size = address.Size;

			if (UDT_ERROR == API_Getpeername(newHandle, addressBuffer, out size))
			{
				throw new UDTSocketException(API_GetLastErrorCode(),
											API_GetLastErrorMessage());
			}
			IPEndPoint localEndPoint;

			if (address.Family == AddressFamily.InterNetwork)
				localEndPoint = new IPEndPoint(IPAddress.Any, 0);

			else
				localEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
			localEndPoint = (IPEndPoint)(localEndPoint.Create(address));

			//---- Tracing
			UDTTrace("UDTSocket[" + _handle + ", new:" + newHandle + "]-Accept:" + remoteEndPoint.ToString());

			//---- Return the new socket
			return new UDTSocket(newHandle, _socketType, remoteEndPoint, localEndPoint);
#endif
		}
예제 #10
0
		public UDTAsyncResult(int size, object stateObject, UDTSocket socket, int overlappedIoHanlde)
		{
			_size = size;
			_stateObject = stateObject;
			_socket = socket;
			_overlappedIoHanlde = overlappedIoHanlde;
		}
예제 #11
0
        public UDTSocket Accept()
        {
#if UDT_FULLTCP
            System.Net.Sockets.Socket newSocket = _tcpSocket.Accept();
            UDTSocket newUDTSocket = new UDTSocket(newSocket);

            // Tracing
            UDTTrace("UDTSocket[" + _tcpSocket.Handle + ", new:" + newSocket.Handle + "]-Accept:" + newSocket.RemoteEndPoint.ToString());

            return(newUDTSocket);
#else
            //---- UDT
            EndPoint      localEP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
            SocketAddress address = ((IPEndPoint)localEP).Serialize();

            byte[] addressBuffer = new byte[address.Size];

            for (int index = 0; index < address.Size; index++)
            {
                addressBuffer[index] = address[index];
            }

            //---- Accept
            int size      = 0;
            int newHandle = API_Accept(_handle, addressBuffer, out size);

            if (UDT_INVALID_SOCK == newHandle)             // UDT::INVALID_SOCK
            {
                throw new UDTSocketException(API_GetLastErrorCode(),
                                             API_GetLastErrorMessage());
            }

            //---- Get the IP+port of the peer socket (RemoteEndPoint)
            for (int index = 0; index < address.Size; index++)
            {
                address[index] = addressBuffer[index];
            }

            IPEndPoint remoteEndPoint;

            if (address.Family == AddressFamily.InterNetwork)
            {
                remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
            }

            else
            {
                remoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
            }
            remoteEndPoint = (IPEndPoint)(remoteEndPoint.Create(address));

            //---- Get the IP+port of the socket (LocalEndPoint)
            size = address.Size;

            if (UDT_ERROR == API_Getpeername(newHandle, addressBuffer, out size))
            {
                throw new UDTSocketException(API_GetLastErrorCode(),
                                             API_GetLastErrorMessage());
            }
            IPEndPoint localEndPoint;

            if (address.Family == AddressFamily.InterNetwork)
            {
                localEndPoint = new IPEndPoint(IPAddress.Any, 0);
            }

            else
            {
                localEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
            }
            localEndPoint = (IPEndPoint)(localEndPoint.Create(address));

            //---- Tracing
            UDTTrace("UDTSocket[" + _handle + ", new:" + newHandle + "]-Accept:" + remoteEndPoint.ToString());

            //---- Return the new socket
            return(new UDTSocket(newHandle, _socketType, remoteEndPoint, localEndPoint));
#endif
        }