|
I changed the linger time limit and that seemed to fix the problem. I'm monitoring it though to make sure. Thanks! Shannon O'Donnell -----Original Message----- From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Wednesday, April 07, 2004 10:52 PM To: Midrange Systems Technical Discussion Subject: Re: Socket Question > Everything works really well, except that after the second or third (I > think) rendition of the socket listener spawning a new job the whole > thing just kind of hangs as if the sockets are all used up. > Now...using Scott's design, I spawn about 10 socket instances from > the single socket listener and from there as each spawned job > finishes, I terminate the program and the main socket listener spawns > another socket, reusing that now closed socket port. And, as I say, it > works fine for awhile, but at some point it all just hangs. To "fix" > this, I end the socket jobs and restart them. Then everything works > fine again for awhile, until, once again it hangs. If you change the backlog parameter to the listen() API, does it have any affect on how quickly the "hang" happens? Are you remembering to close the socket in your instance program before it ends? > I'm wondering if the sockets ports are really being freed up like I > think they are or if something else is going on. The port is not supposed to be "freed up" until the listener program ends. In most applications, the listener should remain running all the time, it should not be closed unless you take it down for maintenance or something like that. (Or, perhaps you only want services to be available at certain times of the day, or whatever...) But, it does kind of sound like you're hitting the number of connections allowed on the port at a time. This would imply that you're not closing the sockets, or that they're lingering for a long time. You control the number of connections allowed on the port at a given time by setting the "backlog" parameter of the listen() API. Also, if you want your applications to be robust, make sure you're using non-blocking sockets. There are little timing errors that can cause a blocking socket to get stuck waiting indefinitely. For a robust application, you should ALWAYS use non-blocking. Of course, there are lots of reasons why a program can get "hung up." It might be helpful if you told us what the program is doing when it stops responding, what statement it's executing, etc. If this does turn out to be a bug in the code that I have posted in the tutorial, please let me know about it so that I can correct it. _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.