/// <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); }
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); } }