T
TP-Software
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 AsyncReadCallBack(IAsyncResult asyncResult)
{
//Get the state object
StateObject state = (StateObject) asyncResult.AsyncState;
//Get the socket
Socket socket = state.workSocket;
try
{
//Read data from the client socket
int bytesRead = socket.EndReceive(asyncResult);
if (bytesRead > 0)
{
state.sb.Append(System.Text.Encoding.ASCII.GetString(state.buffer,0,bytesRea
d));
socket.BeginReceive(state.buffer,0,StateObject.BufferSize,0,new
AsyncCallback(this.AsyncReadCallBack),state);
}
}
catch (SocketException e)
{
if (e.ErrorCode != 64)
{
Console.WriteLine(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 AsyncReadCallBack(IAsyncResult asyncResult)
{
//Get the state object
StateObject state = (StateObject) asyncResult.AsyncState;
//Get the socket
Socket socket = state.workSocket;
try
{
//Read data from the client socket
int bytesRead = socket.EndReceive(asyncResult);
if (bytesRead > 0)
{
state.sb.Append(System.Text.Encoding.ASCII.GetString(state.buffer,0,bytesRea
d));
socket.BeginReceive(state.buffer,0,StateObject.BufferSize,0,new
AsyncCallback(this.AsyncReadCallBack),state);
}
}
catch (SocketException e)
{
if (e.ErrorCode != 64)
{
Console.WriteLine(e.ToString());
}
}
}
}
Thnx for any help.
TP.