Hi, I'm trying to write a program to control an external device (connection via crossover cable).
It isn't throwing me any errors but the device is not changing it's setting (I've triple checked the skippy codes). Anyone able to take a look and give me any suggestions would be greatly appreciated.
The connection is initialised as a result of a yes/no message box.
Here is the code:
case DialogResult.Yes:
// "Yes" processing
IPAddress ia = IPAddress.Parse(ipAddress);
IPEndPoint ie = new IPEndPoint(ia, 5555);
Socket sock1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
sock1.Connect(ie);
}
catch (SocketException e)
{
string error = e.ToString();
MessageBox.Show(error, "Problem connecting to host!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
sock1.Shutdown(SocketShutdown.Both);
sock1.Close();
return;
}
try
{
string fMessage = "OUTPut:SQUelch ON";
Encoding ASCII = Encoding.ASCII;
Byte[] ByteGet = ASCII.GetBytes(fMessage);
sock1.Send(ByteGet, ByteGet.Length, 0);
MessageBox.Show("Did Squelch change?", "Check.",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
sock1.Shutdown(SocketShutdown.Both);
sock1.Close();
}
catch (SocketException e)
{
string error = e.ToString();
MessageBox.Show(error, "Problem communicating to host!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
sock1.Shutdown(SocketShutdown.Both);
sock1.Close();
return;
}
break;
case DialogResult.No:
// "No" processing
break;
}
}
catch (FormatException fEx)
{
MessageBox.Show(fEx.Message);
}
}

1 answers
Add \n to the control command and always fully read the device documentation to avoid wasting loads of time. Didn't help that I'm new to this so it was entirely conceivable that I'd messed up something else.
Working now!!
answered one year ago by:
151