when to close a socket?

Bjoernke von Gierke bvg at mac.com
Wed Feb 29 07:33:04 EST 2012


I'm pretty sure that sockets do not close themselves automatically. "the socketTimeoutInterval" (and "the socketTimeout" message) is weirdly named, in that it doesn't do anything beyond tell you that time has passed, and does not actually act or closes anything. It just repeats infinitely, as long as there's no traffic incoming or outgoing (depending on wether you're listening or writing).

If you're using libURL, then that one should close the sockets for you, and amassing of unclosed sockets would be a bug in there. On the other hand, if you made the sockets yourself from scratch, they're not closed (note that the remote host might and will close sockets, depending on implementation of the server/client on the other end). If things go weird with slow downs as you described, try to query "the opensockets", and if you got a gazillion entries, then you know why you got slow downs and weird stuff happening ;)

Furthermore, note that windows has a hard limit on parallel open sockets when using their IP stack (and LC does use that one). It's about 128 open sockets or so. Some enterprise-targeted windows editions have different limits tho, and maybe they removed the limit in win7 or vista (been a while since i read up on this stuff).

On 29.02.2012, at 10:49, Terry Judd wrote:

> Hi guys - we have a reasonably complex Livecode app that makes lots of server requests - typically initiated by posting data to php routines on a secure (https) server.  Generally things work well but occasionally things go awry and we start seeing slowdowns and odd errors (including the dreaded 'previous request not completed'), particularly if a number of requests are made in relatively quick succession.
> 
> Anyway, I was wondering whether there was any advantage to closing the open socket as soon as any data is returned rather than waiting for it close itself (there is a timeout interval of 5 seconds), thereby forcing any new request to open a new socket rather than using an 'old' open one?
> 
> We've got around 1200 regular users (students and staff) on this system now and I'm keen to improve the reliability of the network side of things in any way that I can.
> 
> Terry...
> 
> Dr Terry Judd
> Senior Lecturer in Medical Education
> Medical Eduction Unit
> Faculty of Medicine, Dentistry & Health Sciences
> The University of Melbourne
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list