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


C# SocketType类代码示例

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


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

示例1: SingleReceiveLoopProxyReactor

 protected SingleReceiveLoopProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop,
     IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator,
     SocketType socketType = SocketType.Stream, ProtocolType protocol = ProtocolType.Tcp,
     int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE)
     : base(localAddress, localPort, eventLoop, encoder, decoder, allocator, socketType, protocol, bufferSize)
 {
 }
开发者ID:helios-io,项目名称:helios,代码行数:7,代码来源:SingleReceiveLoopProxyReactor.cs

示例2: SslServer

        // Initialize all of the default certificates and protocols
        public SslServer()
        {
            // Initialize the Socket
            serverSocketType = SocketType.Stream;
            serverProtocolType = ProtocolType.Tcp;

            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
            {
                cert = new X509Certificate(CertificatesAndCAs.emuCert, "NetMF");
                ca = new X509Certificate[] { new X509Certificate(CertificatesAndCAs.caEmuCert) };
            }
            else
            {
                // Initialize the SslStream
                cert = new X509Certificate(CertificatesAndCAs.newCert);
                ca = new X509Certificate[] { new X509Certificate(CertificatesAndCAs.caCert) };
            }
            verify = SslVerification.NoVerification;
            sslProtocols = new SslProtocols[] { SslProtocols.Default };

            // Create a TCP/IP (IPv4) socket and listen for incoming connections.
            serverSocket = new Socket(AddressFamily.InterNetwork, serverSocketType, serverProtocolType);
            serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, false);

            serverSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
            serverEp = (IPEndPoint)serverSocket.LocalEndPoint;

            Debug.Print("Listening for a client to connect...");
            serverSocket.Listen(1);
        }
开发者ID:adamlin1970,项目名称:NetmfSTM32,代码行数:31,代码来源:SslServer.cs

示例3: 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

示例4: TZmqServer

		public TZmqServer (TProcessor processor, Context ctx, String endpoint, SocketType sockType)
		{
			new TSimpleServer (processor,null);
			_socket = ctx.Socket (sockType);
			_socket.Bind (endpoint);
			_processor = processor;
		}
开发者ID:ConfusedReality,项目名称:pkg_serialization_thrift,代码行数:7,代码来源:TZmqServer.cs

示例5: TCPClient

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

示例6: Accept

    /// <summary>
    /// Accepts the specified number of incoming connection attempts and creates new <see cref="Socket"/> objects.
    /// </summary>
    /// <param name="addressFamily">One of the <see cref="AddressFamily"/> values.</param>
    /// <param name="socketType">One of the <see cref="SocketType"/> values.</param>
    /// <param name="protocolType">One of the <see cref="ProtocolType"/> values.</param>
    /// <param name="localEndPoint">The local <see cref="EndPoint"/> to associate with the <see cref="Socket"/> that 
    /// will be accepting connections.</param>
    /// <param name="count">The maximum number of connections to accept.</param>
    /// <param name="acceptSocketFactory">Called when ready to accept a new <see cref="Socket"/>, up to the specified <paramref name="count"/>.
    /// This function may return <see langword="null"/> to create new sockets automatically.</param>
    /// <returns>An observable sequence containing the connected <see cref="Socket"/> objects.</returns>
    public static IObservable<Socket> Accept(
      AddressFamily addressFamily,
      SocketType socketType,
      ProtocolType protocolType,
      IPEndPoint localEndPoint,
      int count,
      Func<Socket> acceptSocketFactory)
    {
      Contract.Requires(localEndPoint != null);
      Contract.Requires(count > 0);
      Contract.Requires(acceptSocketFactory != null);
      Contract.Ensures(Contract.Result<IObservable<Socket>>() != null);

      return Observable.Using(
        () => new Socket(addressFamily, socketType, protocolType),
        socket =>
        {
          socket.Bind(localEndPoint);
          socket.Listen(count);

          var e = new SocketAsyncEventArgs();

          return Observable
            .Defer(() =>
            {
              e.AcceptSocket = acceptSocketFactory();		// Work item 23871

              return socket.AcceptObservable(e);
            })
            .Select(r => r.AcceptSocket)
            .Repeat(count);
        });
    }
开发者ID:ibebbs,项目名称:Rxx,代码行数:45,代码来源:ObservableSocket+-+Accept.cs

示例7: 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

示例8: P2PClient

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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: BINLSocket

        public BINLSocket(IPEndPoint endpoint, bool broadcast = false, bool enableMulticast = false, int buffersize = 1024, SocketType type = SocketType.BINL)
        {
            try
            {
                this.localEndPoint = endpoint;
                this.broadcast = broadcast;
                this.buffersize = buffersize;
                this.type = type;
                this.reuseAddress = Settings.ReUseAddress;

                this.socket = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, ProtocolType.Udp);
                this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, this.broadcast);
                this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, this.reuseAddress);

                this.state = new SocketState();
                this.state.Type = this.type;
                this.state.Buffer = new byte[this.buffersize];
                this.state.Buffersize = this.buffersize;
                this.state.Socket = this.socket;

                this.socket.Bind(this.localEndPoint);
                this.socket.BeginReceiveFrom(this.state.Buffer, 0, this.state.Buffersize, 0,
                    ref this.localEndPoint, new AsyncCallback(this.Received), this.state);
            }
            catch (SocketException ex)
            {
                Errorhandler.Report(LogTypes.Error, "[BINL] Socket Error {0}: {1}".F(ex.ErrorCode, ex.Message));
            }
        }
开发者ID:LipkeGu,项目名称:bootpd,代码行数:29,代码来源:BINL.cs

示例14: 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

示例15: 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


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