Solved

How to listen server for 10 Minutes and then terminate

Posted on 2010-08-20
5
467 Views
Last Modified: 2012-05-10
I want my server socket to listen for 10 minutes or for specific time and then terminate the connection. Please guide me how to do this?How can i set the time for this?

0
Comment
Question by:muhammadyasir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 17

Assisted Solution

by:CSecurity
CSecurity earned 375 total points
ID: 33486945
Create a timer, look:
http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithTimerControlinCSharp11302005054911AM/WorkingwithTimerControlinCSharp.aspx

Then on the time you defined, close the connection: Socket.Close()

That's all
0
 
LVL 17

Assisted Solution

by:CSecurity
CSecurity earned 375 total points
ID: 33486965
Create a timer object in your form, then set it's interval to 600000 (it's in millisecond, means 10 min)

Then

private void timer1_Tick(object sender, System.EventArgs e)
{
Socket.Close();
}
0
 
LVL 5

Author Comment

by:muhammadyasir
ID: 33487092
Sorry to say I did write my question properly, i am rephrasing it.

I want my server to listen for 10 minutes if no connection is being received with in these 10 minutes then i have to terminate the server.

Thanks
0
 
LVL 17

Assisted Solution

by:CSecurity
CSecurity earned 375 total points
ID: 33487265
Do this:

If (checkSocket.Connected == false) then checkSocket.close()
0
 
LVL 2

Accepted Solution

by:
omraviprakash earned 125 total points
ID: 33499909
Approach can be taken to start a timer as soon as you have your server listening for the connections. You can set the timer to a value of 10 min. As soon as you have a connection from client coming, you can stop the timer. Else, if the timer timesout in 10min, you can close the server listening port or exist gracefully.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do i create a simple array in a public class? 6 38
history of pages 7 55
Updating Printer Details in VB.Net 16 43
How do you think this website does searches? 5 36
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question