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


C# ProtocolType类代码示例

本文整理汇总了C#中ProtocolType的典型用法代码示例。如果您正苦于以下问题:C# ProtocolType类的具体用法?C# ProtocolType怎么用?C# ProtocolType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SocketAsyncClient

        /// <summary>
        /// 
        /// </summary>
        public SocketAsyncClient(IPEndPoint remoteEndPoint, int bufferSize, AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
        {
            _remoteEndPoint = remoteEndPoint;
            _client = new Socket(addressFamily, socketType, protocolType);
            socketObject = new SocketObject(Guid.NewGuid(), _client);
            int maxConnection = 1;
            int numOfSaeaForRecSend = maxConnection * OpsToPreAlloc;
            _readWritePool = new SocketAsyncPool(numOfSaeaForRecSend);
            int numSize = numOfSaeaForRecSend * bufferSize;
            _bufferManager = new BufferManager(numSize, bufferSize);
            _bufferManager.InitBuffer();

            _saeaProxy = new SocketAsyncEventArgsProxy(bufferSize);
            _saeaProxy.ReceiveCompleted += OnReceiveCompleted;
            _saeaProxy.SendCompleted += OnSendCompleted;
            _saeaProxy.ClosedHandle += OnSocketClosing;

            SocketAsyncEventArgs saea;
            for (int i = 0; i < numOfSaeaForRecSend; i++)
            {
                saea = _saeaProxy.CreateNewSaea();
                _bufferManager.SetBuffer(saea);
                saea.UserToken = new DataToken(saea.Offset);
                _readWritePool.Push(saea);
            }
        }
开发者ID:rongxiong,项目名称:Scut,代码行数:29,代码来源:SocketAsyncClient.cs

示例2: init

        /// <summary>
        /// Initializes the socket
        /// </summary>`
        public void init(int offset, string ipAddress)
        {
            socketType = SocketType.Stream;
            protocolType = ProtocolType.Tcp;
            //addressFamily = AddressFamily.InterNetwork;
            addressFamily = AddressFamily.InterNetwork;
            try
            {
                ipEntry = Dns.GetHostEntry(Dns.GetHostName());
                IPAddress[] addr = ipEntry.AddressList;
                //endpoint = new IPEndPoint(addr[0], port);
                for (int i = 0; i < addr.Length; i++)
                {
                    Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
                }
                if (ipAddress == "")
                {
                    address = addr[addr.Length - offset];
                }
                else
                {
                    address = IPAddress.Parse(ipAddress);
                }
                Console.WriteLine("Using the Address {0}: {1}", address.ToString(), port);
                endpoint = new IPEndPoint(address, port);
            }
            catch (SocketException ex)
            {
                System.Console.WriteLine(ex.Message);
            }
            createSocket();

        }
开发者ID:EricYoung2011,项目名称:iMonopolyDeal,代码行数:36,代码来源:ServerSocket.cs

示例3: NetworkDevice

 public NetworkDevice(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, EndPoint endPoint)
 {
     _AddressFamily = addressFamily;
     _SocketType = socketType;
     _ProtocolType = protocolType;
     _EndPoint = endPoint;
 }
开发者ID:ncorreia,项目名称:FoursquareMobile,代码行数:7,代码来源:NetworkDevice.cs

示例4: CreateSocket

        public static unsafe SafeCloseSocket CreateSocket(SocketInformation socketInformation, out AddressFamily addressFamily, out SocketType socketType, out ProtocolType protocolType)
        {
            SafeCloseSocket handle;
            Interop.Winsock.WSAPROTOCOL_INFO protocolInfo;

            fixed (byte* pinnedBuffer = socketInformation.ProtocolInformation)
            {
                handle = SafeCloseSocket.CreateWSASocket(pinnedBuffer);
                protocolInfo = (Interop.Winsock.WSAPROTOCOL_INFO)Marshal.PtrToStructure<Interop.Winsock.WSAPROTOCOL_INFO>((IntPtr)pinnedBuffer);
            }

            if (handle.IsInvalid)
            {
                SocketException e = new SocketException();
                if (e.SocketErrorCode == SocketError.InvalidArgument)
                {
                    throw new ArgumentException(SR.net_sockets_invalid_socketinformation, "socketInformation");
                }
                else
                {
                    throw e;
                }
            }

            addressFamily = protocolInfo.iAddressFamily;
            socketType = (SocketType)protocolInfo.iSocketType;
            protocolType = (ProtocolType)protocolInfo.iProtocol;
            return handle;
        }
开发者ID:vbouret,项目名称:corefx,代码行数:29,代码来源:SocketPal.Windows.cs

示例5: SocketManager

 public SocketManager(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
 {
     _addressFamily = addressFamily;
     _socketType = socketType;
     _protocolType = protocolType;
     _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 }
开发者ID:MagnusTiberius,项目名称:WalkerRoad,代码行数:7,代码来源:SocketManager.cs

示例6: Client

 public Client(IPAddress ip, int port, ProtocolType protocol = ProtocolType.Tcp, string connectionKey = "")
 {
     initialized = false;
     key = System.Text.Encoding.UTF8.GetBytes(connectionKey);
     client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, protocol);
     Initialize(ip, port);
 }
开发者ID:eddydg,项目名称:The-Revenge-Of-the-Dark-Side,代码行数:7,代码来源:Net.cs

示例7: Socket_internal

		private IntPtr Socket_internal(AddressFamily family,
		SocketType type,
		ProtocolType proto,
		out int error)
		{
			throw new System.NotImplementedException();
		}
开发者ID:desunit,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:Socket_2_1.Mosa.cs

示例8: IPHeader

        public IPHeader(byte[] byBuffer, int nReceived)
        {
            NetBinaryReader nbr = new NetBinaryReader(byBuffer, 0, nReceived);

            Version = nbr.ReadNible();
            HeaderLength = nbr.ReadNible();

            Precedence = (Precedence)nbr.ReadCustomAmount(3);
            LowDelay = nbr.ReadBit();
            HighThroughput = nbr.ReadBit();
            HighRelibility = nbr.ReadBit();
            nbr.SkipPadBits();

            TotalLength = nbr.ReadUInt16();
            Identification = nbr.ReadUInt16();

            nbr.ReadBit();
            MayFragment = !nbr.ReadBit();
            LastFragment = !nbr.ReadBit();
            FragmentOffset = (nbr.ReadPadBits() << 3) + nbr.ReadByte();

            TTL = nbr.ReadByte();
            Protocol = (ProtocolType)nbr.ReadByte();
            HeaderChecksum = IPAddress.NetworkToHostOrder(nbr.ReadInt16());

            Source = new IPAddress(nbr.ReadBytes(4));
            Destination = new IPAddress(nbr.ReadBytes(4));
        }
开发者ID:Arzana,项目名称:Sniffles,代码行数:28,代码来源:IpHeader.cs

示例9: P2PServer

	public P2PServer(int point,SocketType socketType=SocketType.Dgram,ProtocolType protocolType=ProtocolType.Udp)
	{
		this.point=point;
		this.protocolType =protocolType;
		this.socketType=socketType;
	
	}
开发者ID:TowerSay,项目名称:Tower,代码行数:7,代码来源:P2PServer.cs

示例10: SendAndVarReceive

 /// <summary>
 /// 戻り値をAppVarで取得する通信。
 /// </summary>
 /// <param name="invoker">呼び出し元。</param>
 /// <param name="friendlyConnector">アプリケーションとの接続者。</param>
 /// <param name="protocolType">通信タイプ。</param>
 /// <param name="operationTypeInfo">操作タイプ情報。</param>
 /// <param name="varAddress">変数アドレス。</param>
 /// <param name="typeFullName">タイプフルネーム。</param>
 /// <param name="operation">操作名称。</param>
 /// <param name="arguments">引数。</param>
 /// <returns>変数。</returns>
 internal static AppVar SendAndVarReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
     OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
 {
     object value = SendAndValueReceive(invoker, friendlyConnector, protocolType, operationTypeInfo, varAddress, typeFullName, operation, arguments);
     VarAddress retHandle = value as VarAddress;
     return (retHandle == null) ? (null) : (new AppVar(friendlyConnector, retHandle));
 }
开发者ID:Codeer-Software,项目名称:Friendly,代码行数:19,代码来源:FriendlyTalker.cs

示例11: Reset

			public void Reset (Socket socket, IPEndPoint ip)
			{
				this.addressFamily = socket.AddressFamily;
				this.socketType = socket.SocketType;
				this.protocolTtype = socket.ProtocolType;
				this.RemoteEndPoint = ip;
			}
开发者ID:learnUnity,项目名称:KU_NET,代码行数:7,代码来源:AsyncSocket.cs

示例12: VNESBase

 public VNESBase(IPAddress ip, int port, ProtocolType protocol)
 {
     this.ip = ip;
     this.port = port;
     this.protocol = protocol;
     this.filter = this.BuildFilter();
 }
开发者ID:pmartins,项目名称:VNES,代码行数:7,代码来源:VNESBase.cs

示例13: CreateSocket

 public Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
 {
     SetAddressFamily(addressFamily);
     SetProtocolType(protocolType);
     SetSocketType(socketType);
     return new Socket(this.addressFamily, this.socketType, this.protocolType);
 }
开发者ID:julfycoder,项目名称:Sniffer,代码行数:7,代码来源:SocketBuilder.cs

示例14: CreateConnection

        public static async Task<IDisposableConnection<ArraySegment<byte>>> CreateConnection(
            EndPoint endpoint,
            SocketType socketType = SocketType.Stream,
            ProtocolType protocolType = ProtocolType.Tcp)
        {
            var socket = new Socket(socketType, protocolType);
            bool disposeSocket = false;
            try
            {                
                using (SocketAwaitableEventArgs args = new SocketAwaitableEventArgs())
                {
                    args.RemoteEndPoint = endpoint;
                    await socket.ConnectSocketAsync(args);
                }
            }
            catch (Exception)
            {
                disposeSocket = true;
                throw;
            }
            finally
            {
                if (disposeSocket)
                {
                    socket.Dispose();
                    socket = null;
                }
            }

            return socket.ToConnection();
        }
开发者ID:headinthebox,项目名称:IoFx,代码行数:31,代码来源:SocketUtility.cs

示例15: Socket

 private Socket(AddressFamily family, SocketType type, ProtocolType proto, IntPtr native)
 {
     this.family = family;
     this.type = type;
     this.proto = proto;
     this.native = native;
 }
开发者ID:memsom,项目名称:dotNetAnywhere-wb,代码行数:7,代码来源:Socket.cs


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