예제 #1
0
        /// <summary>
        /// Creates a new StatsdUDP class for lower level access to statsd.
        /// </summary>
        /// <param name="name">Hostname or IP (v4) address of the statsd server.</param>
        /// <param name="port">Port of the statsd server. Default is 8125.</param>
        /// <param name="maxUdpPacketSizeBytes">Max packet size, in bytes. This is useful to tweak if your MTU size is different than normal. Set to 0 for no limit. Default is MetricsConfig.DefaultStatsdMaxUDPPacketSize.</param>
        public StatsdUDPClient(string name, int port = 8125, int maxUdpPacketSizeBytes = MetricsConfig.DefaultStatsdMaxUDPPacketSize)
        {
            _maxUdpPacketSizeBytes = maxUdpPacketSizeBytes;

            _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            IPEndpoint = new IPEndPoint(AddressResolution.GetIpv4Address(name), port);
        }
        /// <summary>
        /// Creates a new StatsdUDP class for lower level access to statsd.
        /// </summary>
        /// <param name="encoding">message encoding</param>
        /// <param name="name">Hostname or IP (v4) address of the statsd server.</param>
        /// <param name="port">Port of the statsd server. Default is 8125.</param>
        /// <param name="maxUdpPacketSizeBytes">Max packet size, in bytes. This is useful to tweak if your MTU size is different than normal. Set to 0 for no limit. Default is MetricsConfig.DefaultStatsdMaxUDPPacketSize.</param>
        public StatsdUDPClient(Encoding encoding, string name, int port = 8125, int maxUdpPacketSizeBytes = MetricsConfig.DefaultStatsdMaxUDPPacketSize)
        {
            _encoding = encoding ?? Encoding.UTF8;
            _maxUdpPacketSizeBytes = maxUdpPacketSizeBytes;

            _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            _ipEndpoint = AddressResolution.GetIpv4EndPoint(name, port);
        }
예제 #3
0
 public StatsdTCPClient(string name, int port = 8125)
 {
     try
     {
         _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         IpEndpoint    = new IPEndPoint(AddressResolution.GetIpv4Address(name), port);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }