C
Chotchkie
Hello,
I am running into a problem with Asynchronous socket communication. I
am developing a simple telnet client to interact with unix. I am
parsing received data for prompts and sending data on found. Problem
is, that sometimes EndReceive returns only a few bytes, much less than
what is in the buffer. Since I am parsing what is in the buffer up to
how large bytes received is, I end up skipping data. Odd thing is
that it works 1/2 the time and fails the rest. Here is some of my
code calls:
to initialize:
s.BeginConnect(ipep,callBackProc,s);
in callBackProc:
AsyncCallback receive = new AsyncCallback(OnReceivedData);
s1.BeginReceive(buffer,0,buffer.Length,SocketFlags.None,receive,s1);
in OnReceivedData:
nBytes = s1.EndReceive(ar); //here sometimes nBytes is X and number of
elements in buffer is Y where X<Y.
also in OnReceivedData to send such things as login, password, etc:
IAsyncResult ar3 = s.BeginSend(tmp,0,tmp.Length,SocketFlags.None,callBackProc,s);
s.EndSend(ar3);
any ideas? anyone run into this problem as well?
Thanks in advance for any help!
I am running into a problem with Asynchronous socket communication. I
am developing a simple telnet client to interact with unix. I am
parsing received data for prompts and sending data on found. Problem
is, that sometimes EndReceive returns only a few bytes, much less than
what is in the buffer. Since I am parsing what is in the buffer up to
how large bytes received is, I end up skipping data. Odd thing is
that it works 1/2 the time and fails the rest. Here is some of my
code calls:
to initialize:
s.BeginConnect(ipep,callBackProc,s);
in callBackProc:
AsyncCallback receive = new AsyncCallback(OnReceivedData);
s1.BeginReceive(buffer,0,buffer.Length,SocketFlags.None,receive,s1);
in OnReceivedData:
nBytes = s1.EndReceive(ar); //here sometimes nBytes is X and number of
elements in buffer is Y where X<Y.
also in OnReceivedData to send such things as login, password, etc:
IAsyncResult ar3 = s.BeginSend(tmp,0,tmp.Length,SocketFlags.None,callBackProc,s);
s.EndSend(ar3);
any ideas? anyone run into this problem as well?
Thanks in advance for any help!