Why does connect callback not timeout when service is lost (while attempting to connect) or the server does not respond?

Submitted by: Administrator
This is due to a bug in the BREW version 1.0.1 SDK - connect callback is not invoked under the following circumstances:

Service is lost while connect is being attempted
Server does not respond

As a workaround, you should implement a timer in association with the callback. If the connect callback does not occur in 30 seconds, you should timeout the connection.

For example:

// initialize pMe->connectCBInvoked = FALSE;

// Set timer for 30 seconds before invoking ISOCKET_Connect()
ISHELL_SetTimer(pMe->a.m_pIShell, 30000, ConnectTimeout_CB, (void *)pMe);
ISOCKET_Connect(pMe->m_pISocket, nodeINAddr, AEE_htons(USAGE_TEST_PORT),
SampleApp_ConnectCB, pMe);

// Set flag indicating connect CB was called
void SampleApp_ConnectCB(void *cxt, int err) {
SampleApp *pMe = (SampleApp*)cxt;

// Set flag indicating connect CB was called
pMe->connectCbInvoked = TRUE;

if (err) {
DisplayOutput((IApplet*)pMe, 3, "Connect failed!");
DisplayOutput((IApplet*)pMe, 3, "Connected!");


// When timer expires, check if connect CB was invoked
static void ConnectTimeout_CB(void* cxt) {
SampleApp *pMe = (SampleApp *)cxt;

if(pMe->connectCbInvoked == FALSE) {
// Callback was not invoked within 30seconds - cancel connect callback
ISOCKET_Cancel(pMe->m_pISocket, 0, 0);
DisplayOutput((IApplet*) pMe, 3, "Connection timed out");

else {
// Callback invoked. Set flag to default value FALSE
pMe->connectCbInvoked = FALSE;

Note: Multiple TCP sockets are not supported on the Kyocera 3035. It allows one TCP socket and one UDP socket at a given time.
Submitted by: Administrator

Read Online Brew Job Interview Questions And Answers