TCP for begginer

Login to reply to this topic.
Thu, 2004-06-24 15:11
Joined: 2004-06-24
Forum posts: 1
I'm writing a Client on symbian , and Im tring to read data from the server , it sends a buffer , and I have problems reading it .
the code is as follow :

/* first I read the length */
   TBuf8<2> tmpBuf;
   iEchoSocket->Read(tmpBuf, iReadStatus);
   User::WaitForRequest(iReadStatus);
   TInt16 BufLen = BigEndian::Get16((TUint8*)tmpBuf.Pt());


/* now I need the all buffer - how should i do it ? */

Thanks .

Thu, 2004-06-24 21:07
Joined: 2003-07-17
Forum posts: 28
TCP for begginer
Hi,

First of all you should supply a bigger buffer if you need to reda more than 2 bytes!. I mean something like

TBuf8<2048> tmpBuf;
Tint NoOfBytesActuallyRead = 0;
iEchoSocket->Read(tmpBuf, iReadStatus);
User::WaitForRequest(iReadStatus);

NoOfBytesActuallyRead =  tmpBuf.Length();

// You have this many bytes read in a single read operation.
// Now you can read first 2 bytes and find out the actual number of
// bytes still to be read so on based on the protocol used

hope this helps

murali
  • Login to reply to this topic.