×
Namespaces

Variants
Actions
(Difference between revisions)

WISE Timeout

From Nokia Developer Wiki
Jump to: navigation, search
ebra (Talk | contribs)
(New page: == Description == == Maemo Platform == <code> int server_start(wise_server* server,int time_out) { struct sockaddr_rc client_addr = { 0 }; socklen_t opt = sizeof(client_addr); ...)
 
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
+
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080617
 +
|author= [[User:Ebra]]
 +
}}
 +
[[Category:Bluetooth]][[Category:Maemo]][[Category:Symbian]][[Category:Symbian C++]][[Category:Porting]]
 
== Description ==
 
== 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 ==
 
== Maemo Platform ==
Line 13: Line 38:
 
     struct timeval timeout;
 
     struct timeval timeout;
 
     fd_set readfds;
 
     fd_set readfds;
 
 
     int error;
 
     int error;
  
Line 26: Line 50:
 
     error = listen(server->server_socket,0);
 
     error = listen(server->server_socket,0);
 
     if ( error ) return error;  
 
     if ( error ) return error;  
 
    sprintf(buf,"Wait time %d sec",time_out);
 
    logger_add_message(logger,buf);
 
 
      
 
      
 
     select(server->server_socket+1,&readfds,NULL,NULL,&timeout);
 
     select(server->server_socket+1,&readfds,NULL,NULL,&timeout);
Line 51: Line 72:
 
== S60 Platform ==
 
== S60 Platform ==
  
 +
<code>
 +
// set to accept incoming connections, active object will handle
 +
iServerSock.Accept(iClientSock,iStatus); 
 +
SetActive();
 +
</code>
 +
 +
<code>
 +
iServerSock.CancelAccept();
 +
</code>
  
 
== Links ==
 
== Links ==
* [[Wireless Information Sharing Engine]]
+
* [[Archived:Wireless Information Sharing Engine]]
 
* [[WISE Protocol]]
 
* [[WISE Protocol]]

Revision as of 09:32, 26 July 2012

Article Metadata
Article
Created: ebra (17 Jun 2008)
Last edited: hamishwillee (26 Jul 2012)

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

59 page views in the last 30 days.
×