By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,646 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,646 IT Pros & Developers. It's quick & easy.

socket connection open for a long time

P: n/a
Jay
I have a client app sending messages over the socket on a certain port.
In the client app: I do this for every message I need to send:
1. Create a socket and connect.
2. Send message
3. Close socket.

The Listener requires that the client keep the socket connected while
sending messages..which is every 20-30 seconds.

My question is: Can I keep the connection open for the whole day? Connect
once in the morning - close at the end of the day?
Is it just a matter of moving the code around to achive this?
Like, create the socket at the application start. Then "send message"
multiple times during the day. At the end of the day, when the app closes,
"close socket"?
Are there going to be any issues with this?
Feb 15 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

You can keep it open for a day or however long. Some issues to deal
with:

1. Silently handle reconnect on disconnect. Only treat as error if
can't reconnect.

2. Perhaps want to disconnect and reconnect if socket has been
connected for a certain amount of time (say max 8 hours). Not sure
this is necessary, but may be good. We have systems that used to
maintain open FTP server connections 24/7 and they mostly didn't have
problems (the one installation we had a problem with was a switch
which was specifically programmed to disconnect our socket 'cause the
IT people didn't want an open socket that long).

3. Timeout. If socket isn't used for x minutes then close the socket.

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Thu, 15 Feb 2007 10:40:24 -0600, "Jay" <Ja*@microsoft.comwrote:
>I have a client app sending messages over the socket on a certain port.
In the client app: I do this for every message I need to send:
1. Create a socket and connect.
2. Send message
3. Close socket.

The Listener requires that the client keep the socket connected while
sending messages..which is every 20-30 seconds.

My question is: Can I keep the connection open for the whole day? Connect
once in the morning - close at the end of the day?
Is it just a matter of moving the code around to achive this?
Like, create the socket at the application start. Then "send message"
multiple times during the day. At the end of the day, when the app closes,
"close socket"?
Are there going to be any issues with this?
Feb 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.