Re: Problem with Socket :(
Are you using a Stream object to write to the socket? If so, you should call Flush() after each write.
Re: Problem with Socket :(
hi, thanks a lot for your answer, here is how i send the bytes ? is that correct ?
i call the changeTextValue method with a string as parameter, like "LEFT", "RIGHT" etc
private void changeTextValue ( string str )
{
byte[] byData = System.Text.Encoding.ASCII.GetBytes(str);
if ( byData.Length > 0 ) {
m_sock.BeginSend (byData, 0, byData.Length, 0, new AsyncCallback(this.SendCallback), m_sock);
}
myText.Text = str;
System.Console.WriteLine (str);
}
protected void SendCallback(IAsyncResult ar)
{
// Retrieve the socket from the async state object.
Socket handler = (Socket) ar.AsyncState;
try
{
// Complete sending the data to the remote device.
int bytesSent = handler.EndSend(ar);
}
catch (Exception e)
{
}
}
Re: Problem with Socket :(
ok, i see what you mean, instead of using the Socket class i can use the TCPClient class, yes i use a stream object to send the message, and i also call the Flush() method on it, but still the same problem, my calls are queued and all sent one the application closed :(
here is my code :
Byte[] data = System.Text.Encoding.ASCII.GetBytes("LEFT");
NetworkStream stream = myTCP.GetStream();
stream.Write(data, 0, data.Length);
stream.Flush();
Re: Problem with Socket :(
How are you reading the data in?