public void Send(Socket client, string data)
{
try
{
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data + "\0");
byteData[byteData.Length-1] = 255;
// Begin sending the data to the remote device.
client.BeginSend(byteData, 0, byteData.Length, SocketFlags.None,
new AsyncCallback(SendCallback), client);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}