Interviewer And Interviewee Guide

Brew Interview Question:

When transmitting large files, do we have to break the file up into packets before sending, or does BREW do this for me?

Submitted by: Administrator
You should simply send what you can, and ISOCKET_Write() will tell you how much data was actually sent. If there is data remaining to be sent, simply offset your data pointer by the amount indicated by your last call to ISOCKET_Write().

For Example:

void CommonWriteCB (void *pUser) {
char *psz = NULL;
int cbWrite;
… … …

SampleApp * pMe = (SampleApp*)pUser;

// pszData is the data to be written
psz = pszData;
cbWrite = STRLEN (pszData);

// Loop till all the bytes are written.
while (cbWrite > 0) {
rv = ISOCKET_Write(pMe->m_pISocket, (byte *)psz,
(uint16)cbWrite);

if (rv == AEE_NET_WOULDBLOCK) {
// No byte were written successfully. Register
// callback to try again later.
ISOCKET_Writeable(pMe->m_pISocket,
CommonWriteCB, (void *)pMe);
return;
} else if (rv == AEE_NET_ERROR) {
// Write Error.
ReleaseNetAndSocket(pMe);
return;
}

// In case of parital write, loop and write the rest
cbWrite -= rv;
psz += rv;
}
… … …
}
Submitted by: Administrator

Read Online Brew Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.