Hi,
This code doesn't seem to work
it always says "there is more data" and also
this method is only called once
private void AsyncReadCallBa ck(IAsyncResult asyncResult)
{
//Get the state object
StateObject state = (StateObject) asyncResult.Asy ncState;
//Get the socket
Socket socket = state.workSocke t;
try
{
//Read data from the client socket
int bytesRead = socket.EndRecei ve(asyncResult) ;
if (bytesRead > 0)
{
state.sb.Append (System.Text.En coding.ASCII.Ge tString(state.b uffer,0,bytesRe a
d));
socket.BeginRec eive(state.buff er,0,StateObjec t.BufferSize,0, new
AsyncCallback(t his.AsyncReadCa llBack),state);
}
}
catch (SocketExceptio n e)
{
if (e.ErrorCode != 64)
{
Console.WriteLi ne(e.ToString() );
}
}
}
}
Thnx for any help.
TP.
This code doesn't seem to work
it always says "there is more data" and also
this method is only called once
private void AsyncReadCallBa ck(IAsyncResult asyncResult)
{
//Get the state object
StateObject state = (StateObject) asyncResult.Asy ncState;
//Get the socket
Socket socket = state.workSocke t;
try
{
//Read data from the client socket
int bytesRead = socket.EndRecei ve(asyncResult) ;
if (bytesRead > 0)
{
state.sb.Append (System.Text.En coding.ASCII.Ge tString(state.b uffer,0,bytesRe a
d));
socket.BeginRec eive(state.buff er,0,StateObjec t.BufferSize,0, new
AsyncCallback(t his.AsyncReadCa llBack),state);
}
}
catch (SocketExceptio n e)
{
if (e.ErrorCode != 64)
{
Console.WriteLi ne(e.ToString() );
}
}
}
}
Thnx for any help.
TP.
Comment