/// <summary> /// /// </summary> /// <param name="indexCatalog"></param> /// <param name="host"></param> /// <param name="port"></param> /// <param name="timeout">Milliseconds</param> public ConnectionBuilder(TSocketSettings socketSettings, string host, int port = 9200, bool isframed = false, int timeout = 0, bool pooled = false, int poolSize = 25, int lifetime = 0) { Servers = new List<Server> {new Server(host, port, isframed)}; Timeout = timeout; Pooled = pooled; PoolSize = poolSize; Lifetime = lifetime; ConnectionString = GetConnectionString(); TSocketSetting = socketSettings; }
public TSocketV2(TSocketSettings settings) : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, settings.SendBufferSize); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, settings.ReceiveBufferSize); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, settings.SendTimeout); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, settings.ReceiveTimeout); this.settings = settings; buildSocketCallback = new AsyncCallback(BuildSocketCallback); receiveCallback = new AsyncCallback(ReceiveCallback); LastError = SocketError.Success; }
public TSocketV2(TSocketSettings settings) : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) { SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, settings.SendBufferSize); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, settings.ReceiveBufferSize); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, settings.SendTimeout); SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, settings.ReceiveTimeout); this.settings = settings; buildSocketCallback = new AsyncCallback(BuildSocketCallback); receiveCallback = new AsyncCallback(ReceiveCallback); LastError = SocketError.Success; }
public ConnectionPool(string host, int port, ConnectionPoolConfig config,bool isframed=false) { if (config == null) throw new ArgumentNullException("config"); _target = new Server(host, port,isframed); _config = config; _socketSettings = config.SocketSettings ?? TSocketSettings.DefaultSettings; if (config.PoolSize > 0) { _useLimiter = true; _connectionLimiter = new Semaphore(config.PoolSize, config.PoolSize); } }
public TFramedTransport(string host, int port, TSocketSettings socketSettings) { if (string.IsNullOrEmpty(host)) { throw new ArgumentNullException("host"); } if (socketSettings == null) { throw new ArgumentNullException("socketSettings"); } if (host.ToLower() == "localhost") { host = "127.0.0.1"; } remoteEndPoint = new IPEndPoint(IPAddress.Parse(host), port); socket = new TSocketV2(socketSettings); }
/// <summary> /// /// </summary> public Connection(Server server, TSocketSettings socketSettings) { Created = DateTime.Now; Server = server; if (server.IsFramed) { var tsocket = new TSocket(server.Host, server.Port); _transport = new TFramedTransport(tsocket); // _transport = new TFramedTransport(server.Host, server.Port, socketSettings); } else { var tsocket = new TSocket(server.Host, server.Port); _transport = new TBufferedTransport(tsocket, 1024); //TODO remove hardcode } _protocol = new TBinaryProtocol(_transport); _client = new Rest.Client(_protocol); }
public TFramedTransport(string host, int port, TSocketSettings socketSettings) { if (string.IsNullOrEmpty(host)) throw new ArgumentNullException("host"); if (socketSettings == null) throw new ArgumentNullException("socketSettings"); if (host.ToLower() == "localhost") { host = "127.0.0.1"; } remoteEndPoint = new IPEndPoint(IPAddress.Parse(host), port); socket = new TSocketV2(socketSettings); }