Hi,
I am using a buffer to read in an integer from a server. I am using the CSocketRead class from the socket example. Is it recieving a new integer everytime it calls the RecvOneOrMore function? or it requires many operation to recieve 1 integer? Below is a segment of my code in my RunL function. I want it to read in a new integer each time and store it into my array which will be incremented each time it read in a new integer. However, it is not reading the integer the way I expected. It seems to be storing the same number in the array each time the RunL function runs.
void CSocketsRead::RunL()
{
// Active object request complete handler
if (iStatus == KErrNone)
{
// Character has been read from socket
//iConsole.PrintNotify(iBuffer); // display data on console
TInt num;
num=-1;
TLex8 lexRead(iBuffer);
lexRead.Val(num);//convert to integer
if (num==8)
{
iConsole.SetStatus(_L("Connected"😉,1);
}
else
{
if((num==0)||(num==1)||(num==2)||(num==3)||(num==4))
{
if (x==4)//increment of array
{
x=0;
}
if (y==8)
{
x=x+1;
y=1;
}
else
{
y=y+1;
}
oppGrid[x][y]=num;//store integer into array
}
}
IssueRead(); // Immediately start another read
}
else
{
// Error: pass it up to user interface
iConsole.ErrorNotify(_L("\nCSocketsRead error"😉, iStatus.Int());
}
}
void CSocketsRead::IssueRead()
{
// Initiate a new read from socket into iBuffer
ASSERT(!IsActive());
iSocket.RecvOneOrMore(iBuffer, 0, iStatus, iDummyLength);
SetActive();
}
Is there any problem in my code?
Thanks a million,
zhen
:black: