Solved

How to listen server for 10 Minutes and then terminate

Posted on 2010-08-20
5
463 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
  • 3
5 Comments
 
LVL 17

Assisted Solution

by:CSecurity
CSecurity earned 375 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Do this:

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

Accepted Solution

by:
omraviprakash earned 125 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now