How to keep socket alive

Dear All Java Devotees....
I was stucked upon the following socket programming challenge in my projects
first of all I have one Server and one Client
what I wanted initially was client registered to server
when the client abruptly terminated, it wont have any effect at all to the server
But in line with the Java Socket Programming Tutorial
it seems that it cant be done so easily
whenever I close down my client
Server will catch java.net.SocketException: Connection reset
so my question basically :
Is it possible for the Server to keeps iterating in a loop
while listening for a client to register
but here is the catch, I dun want anything severe happen to the Server
when somebody close down the Client abruptly
If possible I would like the server to keep its normal program flow
I mean sort of roll-back to the state before the exception occured
My punchline is to "keep the server program flow"
Any Idea/snippet will be greatly appreciated....
best regards,
Honggo

Hi Joey
sorry I've misled you
I've managed to solve the problem though
but now facing a new problem
I will be grateful if u come across the same problem
here is the scenario:
1. client starts
2. server stars
3. client & server bound to socket
4. client sending some information to server
5. server stops
I've followed your suggestion to use for loops and spawn a new thread for each accepted socket
it's a very simple & helpful idea, but as I observer i hit some shortcomings. I wish you could enlighten me with snippet of code, perhaps :D
after steps 5 which is when the server stops, client is unaware that server has already dead.
i've tried every methods described in the API (e.g. isClosed, isConnected, etc) but client didnt catch exception when client is sending some infomation to the "deceased" server.
So my question: How to detect whether or not the server is dead (in client).
regards,
Honggo

Similar Messages

  • How to keep connection alive?

    I wondering if there is any way to keep connection alive during some period of inactivity.
    I have the SQL Developer 1.2.1 (it is not easy to update as I have no admin privileges on work computer) under Windows XP, connecting to Oracle9i Enterprise Edition Release 9.2.0.6.0.
    The inconvenience is that the connection become dropped after some inactivity time.
    What I have to do is to disconnect and connect again. But if I run any query in dropped connection condition it would take long time before it come back with a message that there is no connection.
    I could not find any kind of 'stay connected' option. (Like it is in some other application with time set possibility to send a some request to a server just to stay connected (for exm: PuTTY))
    To do it by myself it would be done by having some continuously looping script, that would run some simple select (say, sysdate) periodically, but I do not know if it possible to do it from SQL Developer.
    If it done in PL-SQL, it will be processed in Oracle, not in SQL Developer; so, it is not useful.
    Does anybody have or know any suggestion or advice to keep connection stay active?
    Appreciate any help!
    Alex
    Message was edited by:
    alex5161

    The trouble is shared connections. While the dbms_lock.sleep is sleeping, the connection will be frozen.
    Having said that, the real solution is to fix how sqldeveloper handles lost connections. Session timeouts are usually there for a reason and client software needs to learn to live with it.

  • How to keep homesharing active from iTunes on Lion OS?

    I have 4 Macs (w MBPs, 1 iMac, 1 Mac Mini) and 2 Apple TVs (latest). Only the Mac Mini is on Lion OS (10.7.4) since that is what it came with new. I use it to serve my media to the Apple TVs, but they can also get served from the other 3 Macs (all on Snow Leopard 10.6.8).  Only the Mac Mini on Lion drops homesharing when not in use - the other Macs on Snow Leopard keep homesharing alive. While it is actively streaming, the Mini does not drop the feed.  I have the Mac Mini set to never go to sleep or or to screen saver, so it should remain accessible via homesharing.  But if I don't use it for an hour or two, it drops out of homesharing - and it is the only Mac to do so.  I can get it back by quitting then restarting iTunes or by shutting down homesharing and restarting it while keeping iTunes open.  Of course, a restart of the mini would also bring back full functionality.  None of these are acceptable when you are sitting in another room trying to access media via Apple TV.  As a result of the above, I am assuming that the problem is isolated within Lion OS and how it supports iTunes.
    I have seen other discussions claiming Apple TV drops out, but my problem is definitely the Mac Mini on Lion since at the same time I can see it drops from the other Macs and not just from Apple TV - all homesharing devices lose sight of the Mini but keep seeing each other.
    I'd love to downgrade my Mini to Snow Leopard but apparently can't. I'd buy an older used Mini, but I need HDMI - so, I'm stuck until this is fixed. My other devices will definitely stay on Snow Leopard until I see this problem resolved by Apple.
    Any suggestions on how to keep homesharing alive with iTunes on Lion?

    Everything that is on your ipod should also be on your computer.  is it not?
    You can redownload some purchases:
    Downloading past purchases from the App Store, iBookstore, and ...

  • How to keep applet's JFrame alive as browser's closed or, goes to other URL

    My applet has a JFrame that pops up when the applet is downloaded. Right now, if the browser goes to a different page or, if it is closed, the frame disappears.
    I would like to know how to keep the frame alive.
    Thanks.

    These comments applies to using the Applet PlugIn.
    One annoying thing about using the PlugIn is that every time you browse from your applet's page and return, it is destroyed and reinstantiated and then init'ed instead of just stop and start applied on the same applet object. One solution to maintaining state across multiple instances is to use static data. Here is an example that does this with a JFrame, since that is what the poster mentioned, although I usually just do this for the UI on the web page itself.
    This doesn't keep the frame visible when off the web page, but that seems to go against basic applet behavior.
    --Nax
    public class Applet1 extends JApplet
    {     private static JTextArea ui = new JTextArea();
         public void init()
         {     JFrame f = new JFrame("example");
              JScrollPane sp = new JScrollPane(ui);
              f.getContentPane().add(sp);
              f.setSize(200,200);
              f.setVisible(true);
    }

  • Socket - keep it alive or reconnect every time you need it?

    Hello, there.
    What would be the better approach for using the Sockets in AS3.
    1st) open one connection and keep it alive until the site unloads?
    2nd) open a connection, use it, and close it when done; then, open again when I need?
    Considering a scenario where some users will make a constant use of the Socket, but others will almost not use it, what would be the better approach? Does an alive Socket connection use too much bandwidth? Does the action of connecting consumes more than keeping it alive? What is your opinion?
    Thank you all!
    CaioToOn!

    I think that kind information  is inposible to be get because it depends of internet connection. From some users the time will be less from the other users.
    Also keep alive msg may depend from protocol and my be only one Byte sendend on every 15 sek ( for example )

  • How to Keep Alive a specific HFM application

    My PRD landscape has 2-3 applications. Whenever any application loads for the first time in the memory, it takes quite some time before it is loaded. Once the application is loaded, the response times are pretty quick and acceptable.
    During specific parts of the day / month, a specific application becomes active. During this time, other applications may or may not be used, but one specific application is definitely used. I want to keep this application's cubes loaded in the RAM, so that response times are quick, whenever the user needs it - whether for the first time or otherwise.
    How to keep alive a specific application's cubes alive and loaded in RAM? I am not looking for general solution like setting the "FM Service" to Automatic (currently it is set Manual) - setting this to Automatic, will affect all applications. However, I am looking for a specific application at a specific period of time.
    I am ok with a custom solution if required. Let me know, what are my options.

    I think you are looking for an inappropriate solution to your problem. Most HFM applications take a few seconds to start up. If your application takes such a long time to start up you really need to examine the root cause. Start by removing the Sub NoInput and Sub Input routines in your rules to see if this is the reason the application takes so long to start.
    If the removal of those routines does not significantly change the startup time, look through the event logs for possible causes. It is possible you have a connection problem with the Oracle database for example, or you have an environment configuration problem where the HFM application servers have a very slow connection to the database server, or possibly the database server performs poorly.
    I strongly suggest you investigate these root casues first before trying to make HFM behave in a non-standard way. Certainly you can start the HFM Management Service, which will start all of your HFM applications and keep them all up and running. This approach does not allow the applications to shut down on their own though. Only use this if you have exchausted your investigations (as I suggsted above).
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to keep alive RS232 connection

    Hello everyone. I have a problem with RS232 communication. To activate the connection I have to send the string "RS232", then to keep it alive I have to send every second CR, but in the meantime, I must be able to send other character strings without delay on the same port (COM7). Can anyone help me?
    Thanks 
    Solved!
    Go to Solution.

    RS232 standard does not require by itself to be kept alive someway, so I suppose is your remote device that requires it.
    In every case, you could create a 1-sec timer and have its callback send CR periodically over the serial port.
    To avoid conflicts between this task and the rest of the application you could use a lock: basically, after creating the lock, each function that wants to access the serial port must call CmtGetLock (), operate on the port and call CmtReleaseLock () afterwards. If the lock is owned by another function, other functions trying to get access are frozen waiting for the lock, so you must be careful in designing com-related function so that they are fast. If you do not want to have some function be blocked while waiting for the lock you can use CmtTryToGetLock instead of CmtGetLock. A few informations on locks can be found in this tutorial as well as in this chapter of the Programmer reference.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • IPad / iPhone ios 6 needs "keep network alive" option.

    I know this has been discussed in other posts, but a change occured from iOS 5 to iOS 6 where the network connection is no longer maintained after the screen goes to the lock screen.  I use my iPad at my place of work and always have it upright so I can see any new emails / push notifications that come through.  The screen turning on and showing the message is a nice alert to let me know I need to look at my email etc.  This has been working ever since I have had my iPad 3rd generation until I updated to iOS 6.  The device loses the internet connection so no more alerts come through.  VERY frustrating.  I have the latest version of iOS 6 and this issue hasn't been addressed and doesn't look like it will be addressed in the forthcoming 6.1 update. 
    I understand the need to preserve battery life, so this may not be desired functionailty for many.  PLEASE give us the option to keep WiFi alive if there are no plans to put it back to the functionailty of ios5.  Thanks for the ear.
    -Mark

    Try #5.
    Some things to try first:
    1. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    2. Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    3. Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    4. Go into your router security settings and change from WEP to WPA with AES.
    5.  Renew IP Address: (especially if you are droping internet connection)
        •    Launch Settings app
        •    Tap on Wi-Fi
        •    Tap on the blue arrow of the Wi-Fi network that you connect to from the list
        •    In the window that opens, tap on the Renew Lease button
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    iOS 6 Wifi Problems/Fixes
    Fix For iOS 6 WiFi Problems?
    http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
    Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
    http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
    How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
    http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
    iOS 6 iPad 3 wi-fi "connection fix" for netgear router
    http://www.youtube.com/watch?v=XsWS4ha-dn0
    Apple's iOS 6 Wi-Fi problems
    http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
    ~~~~~~~~~~~~~~~~~~~~~~~
    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    WiFi Connecting/Troubleshooting http://www.apple.com/support/ipad/wifi/
    How to Fix: My iPad Won't Connect to WiFi
    http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
    iOS: Connecting to the Internet http://support.apple.com/kb/HT1695
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
    How To Fix iPhone, iPad, iPod Touch Wi-Fi Connectivity Issue http://tinyurl.com/7nvxbmz
    Unable to Connect After iOS Update - saw this solution on another post.
    https://discussions.apple.com/thread/4010130
    Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • How to keep multiple function modules under one Web service

    Hi Experts,
    I have Three RFC function modules and i need to create one web service for these three RFC function modules. I know How to crearte a web service for one function module.
    please suggest me How to keep multiple function modules under one Web service.
    Thanks in advance
    Lakshminarayana

    Hi Lakshmi,
    The best way to do it is to assign all the three RFC Enabled FM's to one function group. Later on the top menu in Utilities you get an option to Create a Webservice from a Function Group.
    You can create one single Webservice using all the the 3 FM's.
    I hope this helps.
    Thanks,
    Manu

  • How to keep FI posting period (OB52) closed but keep CO posting periods (OK

    Hi SAP Guru's,
    how to keep FI posting period (OB52) closed but keep CO posting periods (OKP1) open.
    I.e. on Oct 21th the FI posting period 10 should be open but FI posting period 09 should be closed. But on Oct 21th the CO posting period 09 should be open.
    Thanks in Advance.
    RV

    You've already activeted. You can check in IMG-Financial Accounting Global Settings (New) ® Ledgers ® Real-Time Integration of Controlling with Financial Accounting
    Check this for more info http://help.sap.com/saphelp_dimp50/helpdata/en/22/c2cf4031288131e10000000a1550b0/content.htm

  • How to keep file name in print queue when printing crystal report

    We are using VB .Net 2003 + Crystal Report 2008 SP2 up to Fix Pack 2.6
    When the VB program spools crystal report files to print queue, the print queue only shows "Crystal Report" for each document.  How to keep the original file name?  In the past when we were using Crystal Report 11, the original file name can be shown in the print queue.
    Please help because it's so important for operation to see which report is failed in printing when reports are printed in batch.
    Thanks

    Hello,
    Set the PrintOption.JobTitle value for the print job. Here's C# code on how to:
                   System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
                CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptionsClass();
                CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions newOpts = new PrintOptionsClass();
                   pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;          
                   rasPROpts.PrinterName = cboCurrentPrinters.Text;               
                   rasPROpts.PaperSize = (CrPaperSizeEnum)
                        pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;
                // this sets the name of the print job
                rasPROpts.JobTitle = "MYPrintJob";
                   rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
                   MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information );
    Thank you
    Don

  • Macbook Pro - How to keep a low cycle count

    hey everyone,
    Basically I purchased a new macbook pro 11 days ago, and My current cycle count is also 11. I am eager to keep my cycle count down this time round as my last macbook's battery died at around the 700 mark (the laptop was around 15 months old at the time) which I am told was very high. The average apparently being around 300 for a computer that old.
    I have also read on other forums that people have managed to keep their cycle counts much much lower than 300 even for laptops over 15 months old.
    So to maintain my battery's life this time round I was wondering if anyone had any tips on how to keep the cycle count down this time round?
    Many thanks,
    Josh

    I should point out that the batteries that seem to survive the longest are those that get used--i.e. relatively high cycle counts. They are like muscles--use them or lose them. I tried keeping cycles down on my first battery and the results were that it made it only 11 months. Most of the "my battery failed..." posts we see here show a low cycle count.
    Also, you've posted a question about a new MBP in the forum for older ones made in Early 2008 and before. As the battery technology in your new MBP is different (and apparently better) and you have other hardware improvement made since 2008, you should use the forum for the current-generation MBPs here:
    http://discussions.apple.com/category.jspa?categoryID=251
    Not to worry. It's not your fault you found the wrong forum. "Original MacBook Pro" is a pretty non-intuitive label! About a dozen people a day with new MBPs end up here and sometimes get inappropriate advise if responders either don't notice of can't tell that the OP is asking about a newer Mac.

  • How to keep all text and formats the same on multiple computers?

    I'm creating a file in InDesign CS6 on my Windows computer. I keep everything on my flash drive. When I go to school, I bring my flash drive with me and open it up on the Mac computer, but then there are are compatibility issues. There seems to be missing fonts and formats but the school uses the same version of InDesign I do. Now I was told a lot of things of how to keep the fonts and formats the same (embed the links, package the files, outline the text, save as IDML). However, it is not clear to me what each of those options do, so I don't know when or why to use them. So I just want to make sure that when I bring in my file in next Monday, I won't have any missing fonts or formats. What would you suggest is the proper things to do to keep everything the same on multiple computers? And could you please explain why?

    If you want cross-paltform comaptibility limit the fonts to OpenType or Windows TrueType formats, both of which work on both Mac and PC. To avoid missing font warnings the fonts must either be installed on each computer, or they must be in a folder named Document Fonts in the same location as the .indd file they are to work with. Packaging the file will build taht folder for you.
    the rest of the stuff in your list won't help you. .idml would allow you to open on an older version, but does nothing for your situation. Embedding the links will keep you from having missing links, but so will packaging, and embedded links will make the file much larger and harder to work with.
    For goodness sake, don't even think about outlining the text. It stops being text when you do that and you can no longer edit it.
    And finally. do yourself a big favor and don't attempt to actually work on your file directly from the flash drive. Copy the whole package folder to the hard drive, work on it, then copy back. You don't want to know how many files are fatally damaged by write errors on flash drives.

  • Does anyone know how to keep all songs in the same album when they say featuring someone?

    Each time I load a CD onto Itunes that has an artist who features another artist on that particular song, it puts it in my library as a separate CD even though it will have the same album listed.  For instance Lady Gaga's song just dance features Colby O'Donnis that song is in its own spot while the rest of the cd is together that one song is separate and I don't know how to keep them all together.  Someone help.

    Get the Informations for that song and have a look in the "Sorting" area if there is something different. The data inserted there is just for how iTunes will order the songs.
    If the Interpret in the general informations is "Lady Gaga" and in the sorting area is "Lady Gaga feat. xxxx" than you'll see Lady Gaga as the interpret but it's sort to a second entry "Lady Gaga feat. xxxx".

  • How to keep songs on iphone, work computer and home computer the same?

    How to keep songs on iphone, work computer and home computer the same?
    This seems like something everyone would want to do. I don't know why Apple won't give us a simple solution. They could even charge us for it. I would pay!
    Has anyone solved this? What is your solution?
    Thanks!
    [email protected]

    If you just want to be able to sync your devices to the same PC without having them get overwritten all the times, here is a free method
    http://cnettv.cnet.com/sync-your-ipod-two-computers/9742-1_53-50004835.html
    Basically, you put the same itunes database file on all the PCs. This fakes itunes into thinking it is always the same PC and the ipod is OK to sync with it. It will NOT keep your libraries truly synced, though. I've just resigned myself to always buying from one PC and manually transferring the content to other PCs I want it on.

Maybe you are looking for

  • Redirect undeliverable mail to avoid backscatter?

    Hi, I'm migrating from an old Sun server "appliance" and there was a way to redirect any undeliverable messages. We got tons of spam coming to addresses like [email protected] when there was no Fred at our company. So the messages would bounce to the

  • Audio Commentary  aka  alternate audio file for movie.. How?

    Hi folks, I love this discussion group btw... awesome... So, I've got my feature film done, we did a 1 week run at the theatre now, we are almost ready for our DVD release but want to do one of those really cool Director Actor commentary / alternate

  • How do I update IPad to ios5?

    How do I update my IPad to ios5?

  • Prerequisite test fails while agent deployment

    Hi, I am try to deploy agent 10g on solaris server with oracle 9i. but the prerequisite test fails with the following error. h1. Manual Fixes (1) The following corrective actions need to be taken before proceeding. For your convinience check mark eac

  • CRM search, request return nothing

    Hi, When I try to make research in our b2b applications (CRM 5, TREX 7 update26) if I use the character "*" it return all items, but any other character, (join, union) returns nothing for any requests. I have the following error : "An exception has o