I am trying to decode and reverse a message from another IP, but it doesn't seem to work. When the message is sent it displays "System.Char[]" upon being reversed by converting the string to an array and reversing it. My next goal for this is to then decode it using a method beyond this snippet. If this is really obvious I am sorry, I am a new C# programmer and classed as a "Script Kiddie".
private void MessageCallBack(IAsyncResult aResult)
{
try
{
int size = sck.EndReceiveFrom(aResult, ref epRemote);
if (size > 0)
{
byte[] receivedData = new byte[1464];
receivedData = (byte[])aResult.AsyncState;
ASCIIEncoding eEncoding = new ASCIIEncoding();
string receivedMessage = eEncoding.GetString(receivedData);
char[] rMessage = (receivedMessage.ToCharArray());
Array.Reverse(rMessage);
listMessage.Items.Add("Anonymous: " + rMessage);
}
byte[] buffer = new byte[1500];
sck.BeginReceiveFrom(buffer,
0,
buffer.Length,
SocketFlags.None,
ref epRemote,
new AsyncCallback(MessageCallBack),
buffer);
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
}