Solved

How to listen server for 10 Minutes and then terminate

Posted on 2010-08-20
5
466 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

Independent Software Vendors: 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 to repeat the data 4 30
Asp.net 4 FileUpload gets "Permission Denied" when Uploading file 8 33
Set custom font WPF 2 21
Need help with another query 10 36
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

740 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