After closing serversocket, process remains

Hi everyone,
I'm trying to learn to write a client/server program. I begin by creating a serversocket and waiting for data. When I close the program, the serversocket still remains even when I create handlers that try to close the socket after the GUI has been closed.
The server is as follows:
try
               ServerSocket myServerSocket = new ServerSocket(6666);
               myServerSocket.setReuseAddress(true);
               writeToDebugger("Server successfully created.  Listening on port 6666\n");
               //     open a socket for listening for multiple requests
               while(listening)
                         clientSocket = myServerSocket.accept();
                         //clientSocket.setReuseAddress(true);
                         writeToDebugger("Client " + clientSocket.getInetAddress().toString() + " accepted.");
                         //store clientSocket information
                         out = new PrintWriter(
                                clientSocket.getOutputStream(), true);
                         in = new BufferedReader(
                                  new InputStreamReader(
                                      clientSocket.getInputStream()));
                         while ((inputLine = in.readLine()) != null && inputLine != "")
                              writeToDebugger(inputLine);
                         //breaker = inputLine.indexOf(',');
                         //store the incoming request's information --- username of requestor is first param, requested username is second param
                         //database.put(inputLine.substring(0, breaker), clientSocket.getInetAddress());
                         //return the IP address of the username lookup
                         //out.print(database.get(inputLine.substring(breaker+1)));     
          }Here is my closing handler:
public void windowClosed(WindowEvent arg0) {
          listening=false;
          try
               System.out.println("CLOSING FOR REAL");
               if(clientSocket!=null)
                    clientSocket.close();
                    clientSocket.shutdownInput();
                    clientSocket.shutdownOutput();
               if(myServerSocket!=null)
                    myServerSocket.close();
               if(out!=null)
                    out.flush();
                    out.close();
               if(in!=null)
                    in.close();
               System.out.println("DONE CLOSING");
          catch(Exception e)
               System.out.println(e.getMessage());
     }If someone could please tell me why I have to go into the task manager to close the process after I have already closed the GUI, I'd really appreciate it.
Thanks in advance,
Julian

And you're doing all these closes in the wrong order, and redundantly.
Just close 'out' and the ServerSocket, doesn't matter in what order here.
All the other closes and shutdowns are redundant. Calling shutdownXXX after closing the socket does nothing (and calling them just before closing the socket would add nothing to what close() already does). Closing the client socket before closing the output stream built around the socket output stream denies the output stream the chance to flush.

Similar Messages

  • Firefox apears in firewall even after closing all processes and continues to download file

    firefox continues to download files even after closing all the processes, this behavior was noticed by looking at the my firewall activity log. I am using get them all download manger (firefox extension) to download files in firefox. When first time firefox is started after starting computer it doesnt have any problem, but once I open the download manager and start downloading files it never stops.
    I am using : down them all version 2.05 beta on FF 3.6.12
    1. start computer
    2. open firefox
    3. check firewall status (bitdefender firewall running at report level) - no activity noticed
    3. add url to download file in download them all manager
    4. start download - bitdefinder shows firefox accessing internet
    5. pause download
    6. check firewall status - bitdefinder doesn't show firefox accessing internet in process listing but it does show network activity is going on at its peak.
    7. close all firefox windows and remove firefox.exe from task manager
    8. check bit defiender firewall status it continues to run at peak eating up all the network bandwidth
    9. remove rule of firefox from firewall so as it may prompt when firefox try to connect to internet (bit definder firewall is running in report mode for approval for each connection)
    10. as soon as rule removed, bit definder pops up window sayaing firefox is trying to access remote server (same from where the download was earlier started)
    11. Allow the firefox to access it and again it will start downloading in background and bitdefinder shows up internet activity at its peak.

    naah, looks like its problem of firefox, i removed the plugin and tried downloading using the normal download winodw of firefox but same problem, this time it starts picking up item from the download window and continues to download

  • After closing, Firefox still remains in task manager's processes and could not open again!

    I'm using Windows 7 Professional. I installed FireFox version 6.0.2 few days ago. Now I have problem with this. When I close the browser, it was normal .But when I open it again, nothing happens! I open Task Manger of windows, move to processes tab and I see some processes name firefox.exe. After I close all those processes completely, I can open it up. I don't know what exactly the problem is but it makes me feel upset. Please give me more info and the way to solve this. Thanks you so much.

    https://support.mozilla.com/en-US/kb/Firefox%20hangs <br />See '''hang-at-exit'''

  • Reader 9.3 causing IE to stay in processes after closing

    After installing the latest Reader (9.3) for a client, their Internet Explorer remains in memory after closing it completely (iexplore.exe processes stay in task manager).  This wouldn't be a problem because IE still starts back up just fine, but it causes another program they use to hang when they are trying to perform some tasks in it.  When it hangs, I can close out the processes, but there's a 50/50 chance it stops hanging and continues or stays hung up.  After uninstalling Reader, IE closes out fine and immediately, and their other program works fine.  The other program is a little older, most likely a Windows 3.1 16-bit program.  I was not yet been able to disable the Link Helper add-on for IE to see if that was the cause.  Any other ideas?

    Try this:
    Right click on the IE8 icon in the taskbar. A menu pops ups up. Right click again on "Internet Explorer". Then left click on "Run as administrator". I had a different problem with Reader and this solved the problem. The problem I had was I could not save pdf files in IE8. This solved that problem.

  • In the closure of Adobe, the process remains active and takes too much resource processor.   Expected results:The process AdobRd32.exe has to be correctly closed.

    In the closure of Adobe, the process remains active and takes too much resource processor.
    Expected results:The process AdobRd32.exe has to be correctly closed.

    I'm not sure on a Mac, but when I have this issue, I simply kill the thread (task-manager/processes/select the process, kill thread)
    I have had no ill effects doing this.
    It is my belief, it is the cloud, since they have a dcc connection, you can disconnect from the cloud, close everything, and the cloud is still connected to you. This is a feature of their update process I suppose.(speculation)  Additionally, I remember reading somewhere this issue was due to applying administrative permission at the instigation of the installation. (which I do allow *some* trusted companies to have this so updates can be applied during my downtime. ) 
    I have never had any overt issues after killing the thread and I have done that many times.
    Hope this helps

  • I keep getting this message after closing Firefox and attempt to reopen-Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

    I keep getting this message after closing Firefox and attempt to reopen-Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

    See:
    * http://kb.mozillazine.org/Recovering_a_missing_profile
    * http://kb.mozillazine.org/Profile_in_use

  • Firefox process occasionally continues to run after closing browser in XP Pro 64 and uses 50% CPU

    Every once in awhile after closing Firefox 3.6.13 the process continues to run. The way I discover this is my CPU temperature monitor is increasing from 36C to 50C, so I open the Task Manger and see that it is using 50% of the CPU, slowing down the computer. I am running XP Professional 64 bit SP2 with all the latest updates on an Intel E8400 3.0GHz overclocked to 3.6GHz and 4GB dual channel DDR2-1066 at 800MHz. This happens only occasionally, maybe once or twice a month. I just end the task and the temperature of the CPU drops and everything is normal again.

    Norton IPS is apparently a known issue being mentioned in the KB articles:
    *[[firefox will not start]]
    * [[firefox crashes when you open it]]
    * I also found an earlier post on the Norton site http://community.norton.com/t5/Norton-Internet-Security-Norton/Norton-IPS-1-0-Addon-for-FireFox/m-p/25425#M8494 but I am not sure this is still considered a problem.
    What exactly is this IPS extension. I am currently using XPs with Norton's NIS (version 18.6 - it is a paid for subscription). I do have Intrusion Prevention active in NIS but I see no specific extension or program IPS. Is this some optional additional software?
    I did find an explanation but from 2009
    * http://community.norton.com/t5/Norton-Protection-Blog/Intrusion-Prevention-System-IPS-Your-first-line-of-defense/ba-p/124400
    I am NOT using the Norton Toolbar etc. is it these components that are causing the problem i.e safe search etc.
    I am not having problems with firefox hanging or continuing, despite using NIS.
    There is a bug on this https://bugzilla.mozilla.org/show_bug.cgi?id=548945 but that does not seem to have got very far in confirming or resolving the issue. I imagine Norton have a very large userbase and it seems unlikely that the basic NIS is itself incompatible with Firefox.

  • After closing large documents (drawings) the window closes but the process runs still in the background. I open the next document, the same procedure and after dowing this several times the RAM is full the system becoms very slow. what can i do???

    after closing large documents (drawings) the window closes but the process runs still in the background. I open the next document, the same procedure and after dowing this several times the RAM is full the system becoms very slow. what can i do???

    You can always shut it down manually via the Task Manager
    (CtrlShiftEsc)...
    On Mon, Sep 1, 2014 at 3:05 PM, frank koethen <[email protected]>

  • After closing Firefox to use IE8 or any other program, everything is very choppy and slow. I have to go into Taskbar, Processes, and close firefox.exe manually (which is using up all the memory/CPU). Then, and only then, does everything behave normally. W

    After closing Firefox to use IE8 or any other program (like InterVideo to watch a DVD), everything is very choppy and slow. I have to go into Taskbar, Processes, and close firefox.exe manually (which is using up all the memory/CPU and should have closed before). Then, and only then, does everything behave normally. What is going on and what am I doing wrong or missing??
    == This happened ==
    Every time Firefox opened
    == about a couple months ago and happens every time I close Firefox.

    <u>'''Kill Application'''</u>
    In Task Manager, does firefox.exe show in the <u>'''Processes'''</u> tab?
    See: '''[http://kb.mozillazine.org/Kill_application Kill Application]'''
    '''<u>Causes and solutions for Firefox hanging at exit:</u>'''
    '''[[Firefox hangs]]'''
    '''[http://kb.mozillazine.org/Firefox_hangs#Hang_at_exit Firefox hangs at exit (Mozillazine article)]'''
    '''[[Firefox is already running but is not responding]]'''
    <u>'''Safe Mode'''</u>
    You may need to use '''[[Safe Mode]]''' (click on "Safe Mode" and read) to localize the problem. Firefox SafeMode is a diagnostic mode that disables extensions and some other features of Firefox. If you are using a theme, switch to the DEFAULT theme: Tools > Add-ons > Themes before starting Safe Mode. When entering Safe Mode, do not check any items on the entry window, just click "Continue in Safe Mode". Test to see if the problem you are experiencing is corrected.
    See:
    '''[[Troubleshooting extensions and themes]]'''
    '''[[Troubleshooting plugins]]'''
    '''[[Basic Troubleshooting]]'''
    If the problem does not occur in Safe-mode then disable all of your extensions and then try to find which is causing it by enabling one at a time until the problem reappears. You have to close and restart Firefox after each change via File > Restart Firefox (on Mac: Firefox > Quit). You can use "Disable all add-ons" on the Safe mode start window.
    <u>'''''Other Issues''''': to correct security/stability issues</u>
    <u>'''Update Java'''</u>: your ver. 1.6.0.19; current ver. 1.6.0.20 (<u>important security update 04-15-2010</u>)
    ''(Windows users: Do the manual update; very easy.)''
    See: '''[http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates Updating Java]'''
    Do the update with Firefox closed.

  • Image remains after closing window.

    Hi!
    I just purchased my first LCD display (23" Apple) and I immediately noticed an anomaly. When I have a window open, such as mail, after closing, the image of the window remains faintly on the desk top. I can even read the title of the last email etc. The image slowly fades away and disappears but it's somewhat unnerving. An image even remained from the previous user after I switched.
    Is this common? Just a "thing" that LCDs do? After all the hype about xboxes burning in on plasma TVs, I'm a little paranoid.
    Thanks to all for your advice and council !
    Jeff

    Hey Jeff -
    I had a problem with my 23 ghosting a good while back, but I changed the desktop and I haven't noticed it since, I have read of others mentioning the problem, try searching this folder for "ghost".
    This document has some information but from reading posts in the past I suspect the ghosting is partially a hardware issue and some monitors of the same model have it worse than others.
    Patrick

  • On closing Firefox (3.6.15) I finding that although the applicatione ends, the process remains in memory. Any ideas how I can solve this?

    As long as the process remains in memory, Firefox does not restart and if I have any music playing in a site on shut down, the sound continues.
    I can stop the process using task manager and I have twice reinstalled the application without success. In addition there have been times when there is no content in the tools or view menus.

    https://support.mozilla.com/en-US/kb/Firefox%20hangs <br />
    see '''hang-at-exit'''

  • Flash 11.3 does cause plugincontainer to crash after closing FF

    Hi Chris,
    After installing flash 11.3.300.257
    the new flash sandboxed causes the plugincontainer of firefox to crash.
    open yt video, close the tab.
    close firefox (or wait until the process plugincontainer.exe + the newer 2 processes flashplugin in task manager disappear).
    close firefox.
    after closing ff, I go a crash of plugincontaniner.exe.
    no problem with flash 11.2
    => flash 11.3 and his new processes (2)  in task manager (sandbox) cause the firefox's contanier to crash.
    ff13,
    vista 32 sp2.
    the first crash of plugincontainer in my life!!!
    thanks.
    ome evento problema:     BEX
      Nome applicazione:     plugin-container.exe
      Versione applicazione:     13.0.0.4535
      Timestamp applicazione:     4fc8de63
      Nome modulo con errori:     NPSWF32_11_3_300_257.dll_unloaded
      Versione modulo con errori:     0.0.0.0
      Timestamp modulo con errori:     4fc821fc
      Offset eccezione:     64f99903
      Codice eccezione:     c0000005
      Dati eccezione:     00000008
      Versione SO:     6.0.6002.2.2.0.768.3
      ID impostazioni locali:     1040
      Informazioni aggiuntive 1:     27dd
      Ulteriori informazioni 2:     b76caa7c2627bab0b68e16f682ad848f
      Ulteriori informazioni 3:     ff08
      Ulteriori informazioni 4:     4fae96fb14b9fa70f5513f6819ad1b00
    Message was edited by: schützenkönig
    crash log added.

    Hi Chris, I am not alone
    https://bugbase.adobe.com/index.cfm?event=bug&id=3209832
    =>=>   https://bugbase.adobe.com/index.cfm?event=bug&id=3210025
    https://bugbase.adobe.com/index.cfm?event=bug&id=3172259
    or 1) protectionmode=0
    or 2) plugincontainer.exe crashes AFTER closing Firefox (i.e. the container is unable to RE-load the flash plugin for regularly stopping it! therefore: crash).
    I warmly hope that a new version of flash 11.3 for FF will be released in a few days...in the meantime I disable the sandbox (> doing so, the container process in taskmanager ***remains active until I close FF***, as in the past > therofore: no crash
    thanks.
    please let me know if there are good news

  • FIrefox 4 beta does not work anymore. Directly after start-up (my homepage is showing) is firefox hanging, showing an hour glass. No button, URL or whatever can be used, except for the close button. But even after closing firefox, it keeps on running.

    Even after closing down the application, the firefox task remains running in the background and must be killed with Windows Task Control.
    Even deinstalling and installing the latest beta version does not solve it. Unfortunately I have to use Google Chrome Now.

    Ok. I disabled hardware acceleration. The only extension is the McAfee Scriptscan for Firefox 15.1.0, which was already disabled. I then disabled all plugins (Acrobat, Google Update, Intel Identity Protection (2x), Java Deployment Toolkit, Java Platform, MS Office 2013, Quicktime, Shockwave, Silverlight), which were all up to date.
    Normal or safe mode still has same result. No startup, no option button and no customize.
    Thanks for your help. Got any other suggestions?

  • Changes in stock value of the material even after closing period

    The client closes the accounts every month end. Say they close the books of accounts for the month of Jan’07 on 31st Jan 2007. After closing the account they are running MC.9 to know the stock value of different plants for the previous month. i.e.  for the month of Jan’07. But every day when the client runs the MC.9 they found some differences in the stock price & quantity.
    For better understanding, consider they close the period on 31st Jan. When they run the MC.9 on 2nd Feb it shows the value say 100$ and qty of 100. When we run the same report on 4th Feb the value got changed to say 98$ and qty remain same. Again when we run on 6th Feb the value is changed again to say 102$ and stock is 100.
    We checked the MB51 with posting date & entered date. We could not find any back posting.
    What could be the reason for the  variation in the stock price & qty ? Any pointers will be highly appricated.

    Hi Venkat,
    Your previous posting talked about variation in stock value and now you are saying that there are changes in stock qty also. So the better option would be to check those material which has variation and compare them with other standard reports to get a solution. Export the list of material to an excel sheet and compare them with that of the other reports. This would help you to find the materials which has changes and you can narrow down to the root cause. Once you get the material then u can go by posting date and find the movements.
    Hope this helps. Reward if u find it useful.
    regards
    Anand.C

  • Project commitment shows even after closing PO

    Hi,
    I have developed a program to short close PO (in mass).  This program marks Delivery indicator and sets Latest GR Date.
    After running this program POs are short closed and To be delivered qty/value shows zero in MM reports such as ME2N.
    The problem is that this does not close commitments in Project.  When I run PS report (say CJI5), I get those POs as open and the remaining values are still shown as open commitment in PS.
    Please help me understand how to close this project commitment.
    Regards,
    UT

    I think this will work.  I ran RKANBU01 program after closing PO through my program and it successfully closed open commitments.
    I will confirm once I'm done with my testings...
    Thanks a lot!
    Regards,
    UT

Maybe you are looking for

  • JavaBean JSP to Servlet

    Presuming this is an easy one. I have created a JavaBean in a JSP page that submits a form to a Servlet, how do I send the JavaBean to the Servlet? I know how to create a JavaBean in a Servlet and send it to a JSP page but not vise versa.

  • Partition redistribution on node join

    When a new node joins a distributed cache, I imagine that the partition assignment strategy will alter for the cluster in that some partitions must get assigned to the new node.      This must mean that the primary location for some of the keys in th

  • How to cut and paste a web address

    When I copy web addresses into documents they do not come up as a link. I do I create a link in a document or e-mail

  • Is there any Task Manager Application built in Apex.

    Hi Everyone, Im looking for an Apex application that have functionality like MS Project that is Tasking to team members, adding progress on the tasks and scheduling tasks. if someone knows please share its info. I would be very thankful to You. Regar

  • Server Generation Problem

    Hello everybody Need Help with this. I'm trying to generate scripts for build tables, views, packages, etc. for database creation. I've defined different tablespaces, one for tables and one for indexes. But the DDL generated don't assign those tables