Пример #1
0
        public SocketPool(DistributedEndPoint endpoint)
        {
            Contract.Requires(endpoint != null);

            this.ServerEndpoint = endpoint;
            _pool = new ConcurrentStack <Socket>();
        }
Пример #2
0
        /// <summary>
        /// 同步连接
        /// </summary>
        /// <param name="client"></param>
        /// <param name="endpoint"></param>
        public static void Connect(this Socket client, DistributedEndPoint endpoint)
        {
            var addr = endpoint.Addresses.Where(t => client.AddressFamily == t.AddressFamily);

            client.Connect(addr.ToArray(), endpoint.Port);
        }
Пример #3
0
 /// <summary>
 /// 创建sock连接池
 /// </summary>
 /// <param name="endpoint"></param>
 /// <returns></returns>
 public static ISocketPool CreatePool(DistributedEndPoint endpoint)
 {
     return(new SocketPool(endpoint));
 }