public SocketPool(DistributedEndPoint endpoint) { Contract.Requires(endpoint != null); this.ServerEndpoint = endpoint; _pool = new ConcurrentStack <Socket>(); }
/// <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); }
/// <summary> /// 创建sock连接池 /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public static ISocketPool CreatePool(DistributedEndPoint endpoint) { return(new SocketPool(endpoint)); }