How to Identify "if a UDP socket did not receive any packet in a certain time interval".

Posted on 2004-11-15
Medium Priority
Last Modified: 2010-03-31

 The following line of code exists in my program
 where dp is a datagram packet, d is a datagram socket.

  Now, my program waits for a packet to arrive and then depending on what arrived the rest of the program depends., but what i want to do is if this socket does not receive any packet for a certain interval of time , say 5seconds, i want to perform some other task. The difficulty is how do i get out of this line of code, when i dont receive any packet for the predefined interval of time ( and understand that it came to the next line because of "not receiving any packet for 5 seconds"). It just simply does not come out of that line until it receives a datagram packet.

 Thanks and regards,
Question by:prashanth_gurijala
  • 2
LVL 92

Expert Comment

ID: 12590307
set a timeout for the socket:



Author Comment

ID: 12590655
ok, but when the timeout occurs, how will i find out that, it came out of that statement because of timeout.....
LVL 92

Accepted Solution

objects earned 1500 total points
ID: 12590663
a SocketTimeoutException will be throw

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month16 days, 4 hours left to enroll

850 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