Solved

Opening & closing of ServerSocket

Posted on 1997-04-07
2
419 Views
Last Modified: 2006-11-17
I have a program like:

//*********
.....
ServerSocket s1;

s1=new ServerSocket(21);
....
 //invoke a thread to accept multiple connections
new somethread(s1, ..).start();
....
....

public boolean action(Event e, Object arg)
{
if(somethingIsTrue)
 {
  try   {
         System.out.println("going to close ServerSocket");        
         s1.close();      // the program hangs here
         System.out.println("ServerSocket closed");        
       
        }
        catch(Exception e) {     System.out.println("ServerSocket
excpt");   }
 }
.......
}
...
//*******************


I face two problems while running this problem:

1. I am not able to close ServerSocket. It doesn't even throw any
exceptions. The program simply hangs there. Of course, I am able to
close the ServerSocket s1, if I accept connections without invoking
a thread like the one shown above, i.e

 //invoke a thread to accept multiple connections
new somethread(s1, ..).start();

In Java, it appears you cannot shutdown a server and restart it
without quitting the entire program.

2. If a daemon is already on the port 21, any attempt to open
ServerSocket
on the same port should throw some exceptions but nothing happens in
Java.

I use JDK1.0.2 under win95 but if it is fixed in JDK1.1 can I simply
replace java.net package in CLASSES.ZIP in JDK1.0.2 with the java.net
package
in JDK1.1.

Has anyone come across this problem?

Thanks
Parameshwar Babu


--
0
Comment
Question by:pbabu
[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
2 Comments
 
LVL 1

Expert Comment

by:trof
ID: 1219475
Tell us more about your VM implementation. Is it pure java.exe or JView (j++) or what ?
0
 

Accepted Solution

by:
tlandry earned 200 total points
ID: 1219476
Phabu,

Failure of server sockets to close is a known bug in JDK1.02,
at least for Win95/NT.  Simply using the JDK1.1 class files
may not be enought to fix the situation.  You may need
to use the JDK1.1 VM as well, provided Javasoft fixed this
bug in 1.1.

Hope this helps,

Ted
0

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 160
eclipse console opening separately 2 49
jmss example java 2 48
ejb message driven bean mdb creation steps 2 54
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

739 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