Chris Faherty <[EMAIL PROTECTED]> wrote: > > There is an OS bug relating the accept: > > http://oasis.palm.com/dev/kb/article.cfm?id=1496 > The knowledgebase appears to be down at the moment... but thanks for the info. I'll let the list know how it goes when the knowledgebase is working again. > > The open and bind are fine, but when I try to listen I get > a 'port in use' > > error. Does anybody know what this could be? Am I not > closing the socket > > properly? Is there something else I have to do? > > What you probably want is the PalmOS equivalent of: > > setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) > > SO_REUSEADDR lets you create multiple listeners on a particular port. > Otherwise you will have to wait until the linger on the > closing socket is > expired before listening again -- which incidentally the > linger on PalmOS is > busted. That sounded like exactly what I wanted. So I went off and did the PalmOS equivalent: bFlag = true; err = NetLibSocketOptionSet (AppNetRefnum, gListenSocket, netSocketOptLevelSocket, netSocketOptSockReuseAddr, &bFlag, sizeof(bFlag), timeout, &socketErr); Unfortunately I was disappointed to get a "netErrUnimplemented" returned. A quick flick through the PalmOS Reference doc reveals that I probably should have checked the function documentation beforehand, as the "netSocketOptSockReuseAddr" option is indeed unimplemented on the Palm. However, the "netSocketOptSockLinger" option is implemented. So while I can't let multiple sockets use the same port, I can stop the linger so the socket closes immediately, so new sockets can listen on the port straight away. This looked like: linger.onOff = true; linger.time = 0; err = NetLibSocketOptionSet (AppNetRefnum, gListenSocket, netSocketOptLevelSocket, netSocketOptSockLinger, &linger, sizeof(linger), timeout, &socketErr); I initially tried with 'linger.onOff = false' but this didn't work. But setting to true with 0 seconds linger worked. So, my server can now be restarted! Thanks for your help, Cheers Russell -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
