|
|
Classification: |
Java |
Category: |
java.net |
Created: |
01/28/2002 |
Modified: |
02/04/2002 |
Number: |
FAQ-0769 |
Platform: |
ER5, Symbian OS v6.0, Symbian OS v6.1 |
|
Question: With a Java application that uses sockets, the dial-up connection gets terminated immediately the application is closed. But
there is a long delay before termination when I call Close() on the java.net.Socket but don't terminate the application. Why
is this and what can be done about it?
Answer: When a java.net.Socket is first opened, explicitly or implicitly, from Java code, a session is opened by the VM in native
code to allow the host application to communicate with a native socket server which mediates sockets access for all processes.
Even when the socket is closed, this session remains open for a user-specified timeout period. (On the Nokia 9210, for example,
the default value is 5 minutes.) If no further sockets are created during the timeout period or if at any time the Java application
gets closed, the server session will be closed. The dial-up connection will at that point be terminated, virtually instantaneously. The reason for this behaviour of the socket server is that many of its clients (like e-mail or the Web browser) open and
tear down socket connections in rapid succession. It would be inappropriate to require the user to re-establish a dial-up
connection each time this happened, e.g. with each http request.
Obviously the user can reduce the timeout period if wished by modifying it through the Internet settings dialog. But, unlike
with native code, there is no Java API to force the termination of the dialup connection.
|
|
|