protected async Task <bool> SendConfigurationCommandAsync(string hostAddress, ICommandBase cmd) { using (var socket = await ProdysSocketPool.TakeSocket(hostAddress)) { SendCommand(socket, cmd); var ackResponse = new AcknowledgeResponse(socket); return(ackResponse.Acknowleged); } }
private bool SendConfigurationCommand(string hostAddress, ICommandBase cmd) { using (var socket = GetConnectedSocket(hostAddress)) { SendCommand(socket, cmd); var ackResponse = new AcknowledgeResponse(socket); return(ackResponse.Acknowleged); } }
private Socket Connect(IPAddress ipAddress, ConnectCommandBase connectCmd, int sendTimeout) { Socket socket = null; try { socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.IP); if (sendTimeout > 0) { socket.SendTimeout = sendTimeout; } var endpoint = new IPEndPoint(ipAddress, Sdk.IkusNet.ExternalProtocolIpCommandsPort); socket.Connect(endpoint, TimeSpan.FromMilliseconds(1000)); if (!socket.Connected) { socket.Close(); return(null); } var sent = SendCommand(socket, connectCmd); if (sent <= 0 || !socket.Connected) { socket.Close(); return(null); } var ackResponse = new AcknowledgeResponse(socket); log.Debug("Connect response from codec at {0}: {1}", ipAddress, ackResponse); var success = ackResponse.Acknowleged; if (!success) { socket.Close(); return(null); } return(socket); } catch (Exception ex) { log.Warn(ex, "Exception when connecting to codec at {0}", ipAddress); socket?.Close(); return(null); } }