Exemplo n.º 1
0
        /// <summary>
        /// 从IP列表获取有效IP
        /// </summary>
        /// <param name="ips"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        private static string GetValidIp(string ips, int port)
        {
            string[] ipsArr = ips.Split(',');
            foreach (var ip in ipsArr)
            {
                if (ip != "127.0.0.1")
                {
                    Thrift.Transport.TTransport service = new Thrift.Transport.TSocket(ip, port, 300);
                    try
                    {
                        if (!service.IsOpen)
                        {
                            service.Open();
                            return(ip);
                        }
                    }
                    catch
                    {
                        //
                    }
                    finally
                    {
                        if (service.IsOpen)
                        {
                            service.Close();
                            service.Dispose();
                        }
                    }
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        public static void Main(String[] args)
        {
            try {
                Thrift.Transport.TTransport transport;
                transport = new Thrift.Transport.TSocket("suchlol.com", 9090);
                transport.Open();

                Thrift.Protocol.TProtocol protocol = new  Thrift.Protocol.TBinaryProtocol(transport);
                client = new geospatial.thrift.Geospatial.Client(protocol);

                perform(client);
                transport.Close();
            } catch (TException x) {
                Console.WriteLine(x.StackTrace);
            }
        }