Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #389
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: long lasting client socket connection |
| Date | 2012-01-12 22:21 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20120112141650.885@kylheku.com> (permalink) |
| References | <jenlde$i5v$1@dont-email.me> |
On 2012-01-12, Bill M <wpmccormick@just_about_everywhere.com> wrote: > I'm working on a socket client app that makes a connection to a server > and leaves it open. Thinking that since he's repeatedly asking > questions, there's little point in wasting time closing and reopening > again. Are there any good design patterns out there for this I should > take a look at? Yes, the Null Node Pattern: when you don't want something to happen (like closing and re-opening), then omit the lines of code that would cause that to happen. :) But seriously, noe thing you have to watch out for is keeping such connections idle for too long. It's almost impossible to avoid such an application being deployed by someone in a scenario where the client connets trhough one (or more) NAT gateways to the server. When these routers don't see any activity between a pair of destinations, they will expire the mapping entry, and then your connection is gone. So you might want to include in your design the provision for keepalive ping messages (in either direction: server or client initiated). You probably need some kind of layered design: some objects representing the server session, which hides a protocol for exchanging multiple messages with the server within one session. That layer can hide the connecting and re-connecting from the higher application layers.
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
long lasting client socket connection Bill M <wpmccormick@just_about_everywhere.com> - 2012-01-12 16:04 -0600
Re: long lasting client socket connection Kaz Kylheku <kaz@kylheku.com> - 2012-01-12 22:21 +0000
Re: long lasting client socket connection Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-01-13 14:54 +0000
Re: long lasting client socket connection Bill M <wpmccormick@just_about_everywhere.com> - 2012-01-13 15:58 -0600
Re: long lasting client socket connection Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-01-13 22:17 +0000
Re: long lasting client socket connection Bill M <wpmccormick@just_about_everywhere.com> - 2012-01-14 14:43 -0600
Re: long lasting client socket connection Kaz Kylheku <kaz@kylheku.com> - 2012-01-13 22:38 +0000
Re: long lasting client socket connection Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-01-14 00:49 +0000
csiph-web