mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
turn off linger on new sockets; use long enough timeout on name
resolution that can succeed on device.
This commit is contained in:
parent
e098b3b7cd
commit
b64c359075
1 changed files with 16 additions and 5 deletions
|
@ -24,7 +24,8 @@
|
||||||
#include "palmip.h"
|
#include "palmip.h"
|
||||||
#include "memstream.h"
|
#include "memstream.h"
|
||||||
|
|
||||||
#define NETLIB_TIMEOUT 5
|
#define NETLIB_TIMEOUT (5 * sysTicksPerSecond)
|
||||||
|
#define NAMELOOKUP_TIMEOUT (60*sysTicksPerSecond)
|
||||||
|
|
||||||
void
|
void
|
||||||
palm_ip_setup( PalmAppGlobals* globals )
|
palm_ip_setup( PalmAppGlobals* globals )
|
||||||
|
@ -94,9 +95,21 @@ openSocketIfNot( PalmAppGlobals* globals )
|
||||||
0, /* protocol (ignored) */
|
0, /* protocol (ignored) */
|
||||||
NETLIB_TIMEOUT, &err );
|
NETLIB_TIMEOUT, &err );
|
||||||
if ( err == errNone ) {
|
if ( err == errNone ) {
|
||||||
|
NetSocketLingerType lt;
|
||||||
|
|
||||||
open = XP_TRUE;
|
open = XP_TRUE;
|
||||||
globals->nlStuff.socket = socket;
|
globals->nlStuff.socket = socket;
|
||||||
XP_LOGF( "Opened socket %d", socket );
|
XP_LOGF( "Opened socket %d", socket );
|
||||||
|
|
||||||
|
/* Just for grins, turn linger off; suggested by
|
||||||
|
* http://tomfrauen.blogspot.com/2005/01/some-palm-os-network-programming.html
|
||||||
|
*/
|
||||||
|
lt.onOff = true;
|
||||||
|
lt.time = 0;
|
||||||
|
NetLibSocketOptionSet( globals->nlStuff.netLibRef, socket,
|
||||||
|
netSocketOptLevelSocket,
|
||||||
|
netSocketOptSockLinger, <, sizeof(lt),
|
||||||
|
NETLIB_TIMEOUT, &err );
|
||||||
} else {
|
} else {
|
||||||
XP_LOGF( "Failed to open socket: %d", err );
|
XP_LOGF( "Failed to open socket: %d", err );
|
||||||
}
|
}
|
||||||
|
@ -144,10 +157,8 @@ resolveAddressIfNot( PalmAppGlobals* globals, CommsAddrRec* addr,
|
||||||
|
|
||||||
result = NetLibGetHostByName( globals->nlStuff.netLibRef,
|
result = NetLibGetHostByName( globals->nlStuff.netLibRef,
|
||||||
addr->u.ip_relay.hostName,
|
addr->u.ip_relay.hostName,
|
||||||
&niBuf, NETLIB_TIMEOUT,
|
&niBuf, NAMELOOKUP_TIMEOUT, &err );
|
||||||
&err );
|
if ( result == NULL ) {
|
||||||
|
|
||||||
if ( result == 0 ) {
|
|
||||||
XP_LOGF( "NetLibGetHostByName => %d", err );
|
XP_LOGF( "NetLibGetHostByName => %d", err );
|
||||||
} else {
|
} else {
|
||||||
if ( openSocketIfNot( globals ) ) {
|
if ( openSocketIfNot( globals ) ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue