dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Advanced
Feb 24, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Lingering on Sockets

Java's Socket class gives you control over how a socket handles queued data when it closes. This linger-on-close option allows you to dictate whether you want the socket to send out queued data to its peer when the close() method is invoked, and if so, how long after the invocation of the close() call should the socket try to send the data before actually closing the socket. The linger-on-close option is controlled using two methods defined in the Socket class:
 
public int getSoLinger() throws SocketException
public void setSoLinger(boolean lingerOnClose, int timeout) throws SocketException
The first method returns the timeout that is set for lingering on a socket when it closes. The second one sets the lingerOnClose option and the timeout for the linger-on-close. If the lingerOnClose argument is true, the close() call blocks until any data that has been queued for transmission has been sent, or until the timeout has expired. If the timeout expires, any unsent data is discarded. If the lingerOnClose argument is false, the close() call returns immediately and all queued data is discarded.
Ajit Sagar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date