lidds Posted June 21, 2005 Posted June 21, 2005 Hi guys / girls, Just need a bit of advise and guidance on this one. When my application is lauched I try to obtain setting information for my application from my DB server, just by calling a stored procedure. If the server is down then vb.net eventually times out and gives an error, after waiting about 15 secs. If however it connects to the server, I display an icon on my application taskbar to show the user it's connected OK. Now this is where I need the advice, 1) Is there a better way cleaner / quicker to check that I can connect to the server before I try to call my stored procedure??? Have got some code examples on how to Ping a server, is this a good method?? 2) Also is it best / good practice to keep on Pinging (or what ever method) your server say every min. or so to see if your app. is still connected??? I hope that made sense? Your input would be appreshiated. Cheers Simon Quote
mskeel Posted June 21, 2005 Posted June 21, 2005 I'm not a networking expert, but what about socket stuff? I know, for example, if you open a TCP connection it will get rejected if the server is unavailable. UDP on the other hand, you might never know. I guess it all depends on how you are connecting to the server and sending your data. It sounds like you are doing the right thing by trying to connect (and reconnect on failure, right?) over 15 seconds and timing out if you had no connection after that time. Quote
bri189a Posted June 21, 2005 Posted June 21, 2005 As a former network admin I can tell you that I would uninstall your application from every computer on my network if you pinged my servers every minute. Now if it were me I'd have a test conn.Open/conn.Close on a seperate thread as soon as the app started, by default the app would start with a 'connecting' icon. When the thread successfully opened an closed I would have it set a variable, if it didn't I would have it set the same variable...the variable would probably be enum that had the values of None, Failed, Succeeded... I would have a timer start when the app started that would fire an event every second (the timeout would be 1000). The event for that time would check that variable, if it was None I would leave the 'connecting' icon, if it failed, I'd show a 'no connection' icon, and if it succeeded I would show the 'connected' icon, I would then turn of the timer so that it doesn't run indefinitely. That's a off the top of my head idea, I'm sure on paper a better design would emerge. Quote
lidds Posted June 22, 2005 Author Posted June 22, 2005 bri189a, I agree with you not pinging the server. I have spoken to a friend who is a programmer and he suggested a simular thing, just try to connect to the server and database at start-up of app. and as long as I prompt the user in the splash screen to let them know I am connecting to the server he said 15 sec., if it fails, is an acceptable time to wait. Thanks for the input guys, just wanted to make sure I was going down the right route. Simon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.