Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

WISE Timeout

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: ebra (17 Jun 2008)
Last edited: hamishwillee (30 May 2013)

Contents

Description

When the device runs as a Archived:Wireless Information Sharing Engine server there is a need to stop the service after a timeout period if no client connects before it.

The waiting is done syncronously with the Maemo Platform and asyncronously with the S60 Platform.

Maemo Platform

int server_start(wise_server* server,int time_out)
{
struct sockaddr_rc client_addr = { 0 };
socklen_t opt = sizeof(client_addr);
char buf[50];
 
struct timeval timeout;
fd_set readfds;
int error;
 
memset(&timeout,0,sizeof(timeout));
timeout.tv_sec = time_out;
timeout.tv_usec = 0;
 
FD_ZERO(&readfds);
FD_SET(server->server_socket,&readfds);
 
/* put server socket into listening mode */
error = listen(server->server_socket,0);
if ( error ) return error;
 
select(server->server_socket+1,&readfds,NULL,NULL,&timeout);
 
if ( FD_ISSET(server->server_socket,&readfds) )
{
/* accept one connection */
server->client_socket = accept(server->server_socket,
(struct sockaddr *)&client_addr,&opt);
ba2str(&client_addr.rc_bdaddr,server->client_address);
server->client_connected = TRUE;
}
else
{
server->client_connected = FALSE;
return WISE_CONNECTION_ERROR;
}
return WISE_OK;
}

S60 Platform

// set to accept incoming connections, active object will handle
iServerSock.Accept(iClientSock,iStatus);
SetActive();
iServerSock.CancelAccept();

Links

This page was last modified on 30 May 2013, at 06:34.
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×