I need a timer function to ping the server every 5 secs??using threads.

I need a timer function to ping the server every 5 secs??
using threads...i have to use a thread coz i cant use Timer and Timer Task coz clients r on the JDK1.2 version.I have created a thread which keeps checking th ping msg & any server msg is pings 4 the1st time properly but then it just waits to read the response from server but it doesnt but the server shows that it has send the msgs to client???PLEASE HELP URGENT

Few things are not clear from your post, like, are you using sockets and if you are, how are u reading writing to them (ur sample code would help)...
Anyways if you are, are you doing accept on your socket in a while(true) loop or just once... If you do it only once you will get the first ping message but none afterwards if the other side closes and opens new sockets for every send... What I am suggesting is something like the following:
ss = new ServerSocket(port);
while(true)
     s = ss.accept();
     is = s.getInputStream();
     os = s.getOutputStream();
     reader = new BufferedReader(new InputStreamReader(is));
     writer = new BufferedWriter(new OutputStreamWriter(os));
     String in = reader.readLine();
        // do something with this string
        s.close();
        // put some check here to break out of this infinite loop
}// end of While

Similar Messages

  • TS2771 Help! I just restored my ipod touch 2nd gen cos I needed a clear out. I went to sync some music back on, and it seemed to work. However when I went into 'music' it said 'no content'. I tried syncing music 3 times and it did the same every time. Hel

    Help! I just restored my ipod touch 2nd gen cos I needed a clear out. I went to sync some music back on, and it seemed to work. However when I went into 'music' it said 'no content'. I tried syncing music 3 times and it did the same every time. Help!

    Try plugging your ipod into your computer. Then start up itunes. Let it load everything. Then click on your ipod and play a song from your ipod's library. Not your itunes library. If it plays the song, then go ahead and stop it, disconnect your ipod, and check the content once again.
    I had the same problem and beleive it or not, this worked. I synced my ipod like 5 times before finding this answer on the web. Let me know if I need to clerify anything.

  • Latest update of Firefox is REALLLLLY slow. Is it just all the extra functionality that has been added or is there a button I need to press to make it the same speed as it use to be. Can I downgrade to last version?

    Latest update of Firefox is REALLY slow. Is it just all the extra functionality that has been added or is there a button I need to press to make it the same speed as it use to be? I'll have to start usin safari again as this isn't funny anymore
    Can i retro grade back to the last version?

    uninstalled firefox ....deleted all files still remaining under mozilla firefox directory in program files ... to avoid having to reprogram all my settings, reisntall all addons as well .. I did not remove anything from mozilla firefox that is stored in either appdata or under the windows users directory (if any)
    ... the as suggested reinstalled the latest version of the firefox browser using the link you provided in the email ..; tested and several issues still remain present and unresolved ....
    so please this is urgent or I will have to jump browsers and start using chrome .. because we work 14 hours a day 6 (sometimes 7) days a week, to get ready for the launch of our newest venture and we cannot lose that much days on browser related issues ... so please instead of putting me through week long step process .. of do this .. do that .. can you please actually look into the issue from your end .. I use firefox for so many, many years thta I deserve this kind of support .. thnx Robert

  • Calling a method on a remote object to ping the server

    I need a generic way of pinging a server to check if it is still there. Assuming I don't know the methods defined in the remote interface of the server, one way to achieve this would be to invoke one of the Object methods on the server and catch any exceptions. To do this I could call invoke on the RemoteRef interface, but this requires the opnum of the method, and I don't know what these are for the Object methods. Can anyone help, or suggest a better method for pinging the server ?
    William
    For example:
    // my remote service
    Remote service;
    // obtain remote ref
    RemoteRef ref = ((RemoteObject) service).getRef();
    // invoke Object method e.g. hashCode
    ref.invoke( ... );

    if you mean a real ping like windows/unix send from the ping command then it can not be done from jave. you can either connect to the echo port and test it that way or you would have to make a native call.

  • Need to Return immediately and commit the App Module on a different thread

    I have an action that I want to return fast (immediately) but the server processing takes longer than acceptable. The results of the operation don't matter to the page submitting it and I want it to be able to navigate away even if the operation is not complete. I want to either be able to send a non-blocking server event from the browser or on the server side start a new thread that performs the operation allowing the original thread to return immediately. The new thread would need access to an Application Module in order to commit data. How would I go about accomplishing this?
    Some thoughts
    I've tried creating a ConcurrentLinkedQueue and putting the DataControl on the que, then in the other thread I pull it off the que, process and commit the data. This works unless the page is navigated away from. Then calling dc.getApplicationModule(); returns null.
    I thought about using createRootApplicationModule in the new thread (since the new thread has no context) but don't know how that would work
    This is the code in the run method of the new thread. In this example, I'm adding data to the app module in the original thread and committing the data in a new thread.
    (like I said, it works most of the time.)
    Object[] req = (Object[])que.poll();
    DCDataControl dc = (DCDataControl)req[0];
    try{
    ApplicationModule am = dc.getApplicationModule();
    if (am != null){
    am.getTransaction().commit();
    } else{
    System.out.println("AM:null unable to commit ");
    } catch (Exception e){
    e.printStackTrace();
    finally{
    if (dc!= null){ dc.resetState();} // release app module
    }

    Thanks for the replies. I am aware of the inherent risks of running a separate thread within a managed container.
    The use case is a performance logging operation. We have a internal web app used by a network of franchises with over 1000 users. We log response time and performances statistics to the database. When the user clicks to navigate or commit data, the response time that the user experiences is logged after the page has fully rendered either through a PPR or a full submit. This is done by submitting ADFCustomEvent from javascript on the page after rendering is complete.. The event sends up the time difference from when the user first clicked to when the page was fully rendered. This information is then merged with logged events stored on the users Session that shows the name and response time of every query that was executed during the previous request. Depending on the page this could be up to half dozen to a dozen or more queries. The logging operation as experienced by the browser is generally fast (<200ms) but sometimes can be as long as a second or more when the database gets busy. A half second is too long as makes the app appear sluggish if the user can't type or click immediately after the page has finished rendering. The logged data is aggregated so we know exactly how much of the page load was due to a slow browser/network, how much was database time, webservice call time, etc... If it's due to a slow database we can drill down and see which query is the culprit. These performance metrics are critical to operations and are charted throughout the day so we know exactly what our users are experiencing. All of our users use a custom firefox client that we control. Using this logging framework we were able to determine that upgrading to a Firefox 4.0 based client cut browser render time by more than half a second on average. We can also tell what type of hardware the user is running so can place the blame for poor performance where appropriate. We have determined that pages render considerably faster on Windows 7 than on Windows 98 with the same hardware. We are moving the logging tables off of our exadata database to a separate box to remove that load from the application database. Since we expect the other database not to perform as well we don't want it to affect the user experience, hence the need to log asynchronously. I would like to put the data on a queue and have a background daemon process read from the queue and commit to the database. I would like the daemon thread to be able to use BC components. I would prefer not to resort to using a web service because of the inherent overhead. The logging operation is not a long operation but is of high frequency so should be as streamlined as possible. The load is spread over 6 servers with 4 JVM's each (24 weblogic instances). I know it's possible to use BC components from a plain Servlet (which runs on it's own thread) so what I want is to have something like a servlet thread that loops forever processing my logging queue.
    One other method I am investigating is using my own non-blocking ajax call that callls a servlet to perform the logging. I will need to pull out the timestamp contained within a client side ADF component along with the pages ctrl-state variable that is included with every ADF request as it uses this as the key to get to the data on the session. ADF really needs a non-blocking ADFCustomEvent for this type of request. (send and don't care about the response)
    The client component with the server listener looks like this
    <af:outputText value="#{pageFlowScope.perfClientTS}" visible="false"
    id="perfClientTSField" clientComponent="true">
    <af:serverListener type="logPerfData" method="#{perfLog.logPerfDataAction}"/>
    </af:outputText>
    The script that queues the ajax call after the page loads looks like this
    AdfCustomEvent.queue(perfClientTSField, "logPerfData", {
    typeId : typeId,
    subTypeId : subTypeId,
    responseTime1 : new String(responseTime1),
    responseTime2 : new String(responseTime2),
    openedVia: via
    true);
    I also tried calling the noResponseExpected() method on the event before queuing it but it still blocked the UI and caused an additional side effect in that the client sent two ajax requests instead of one. It somehow thought something on the client side needed to be synced with the server.
    email me and I can send a doc with more details about how our performance logging framework works.
    Edited by: Don Kleppinger on Mar 14, 2012 2:52 PM

  • I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server

    I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server, despite following the Systemline instructions that impy this can be done.
    Can anyone please advise what I am doing wrong?

    Hi LowLuster
    Thanks for reply. I am not an expert on these sharing protocols but I think I have turned on SMB sharing but still wont connect. I tried adding netwrik drive by using cntrl K in finder and using smb\\network address but nothing. It is driving me mad!!

  • JSP page display wrong time when compared to the server time

    Hi,
    This problem seems to weird but it is happening
    I have web application running where time is displayed in the page. In this application time is very critical. Currently, time is an hour behind the orginal time.
    I checked the server it is displaying proper time.
    As a matter of troubleshooting, I wrote a java program and run the program in the same server, where the application is running. The java program returns me proper time , but JSP is still displaying time an hour behind. To trouble shoot further, I created a test jsp page to just display the time and accessed the time and the jsp displayed wrong time as well, an hour behind.
    I am running[ tomcat 4.0.3 and j2sdk1.4.3 in suse linux enterprise server 9.0
    My Java program
    import java.util.*;
    import java.text.*;
    public class TestDate
    public static void main(String s[])
         try{
              DateFormat DF = new SimpleDateFormat( "dd/MM/yyyy");
    DateFormat DT = new SimpleDateFormat("hh:mm aa");
              SimpleDateFormat fmt=new SimpleDateFormat("HH.mm");
              Calendar cal= Calendar.getInstance();
              java.util.Date dt=cal.getTime();
              String curdt=DT.format(dt);
              System.out.println("Server Time" + curdt + "\n");
              int hh = cal.get(Calendar.HOUR);
              int mm = cal.get(Calendar.MINUTE);
              int aa = cal.get(Calendar.AM_PM);
              System.out.println("Time" + hh +":"+mm+":"+aa+"\n");
         }catch(Exception e) {
         e.printStackTrace();
    This display Time3:30:1
    My JSP Page
    <%@ page import="java.util.*,java.text.*"%>
    <%
    Calendar calen;
    calen = Calendar.getInstance();
    int hh=calen.get(Calendar.HOUR);
         int mm=calen.get(Calendar.MINUTE);
         int aa=calen.get(Calendar.AM_PM);
    %>
    <%=hh%> <%=mm%> <%=aa%>
    This display 2 30 1
    When I run Date in linux server it gives 3:30 PM EST 2004
    I am really confused, why this is happening, If you have any solutions or idea please post the solution.

    My guess is that the weirdness is caused by Daylight savings time.
    I will presume that you and the server are in the same timezone :-)
    Alternatively it could be caused by getting a different Locale.
    Try the following
    Print out "date.getTime()" value (ie long representing number of millis)
    They should be the same (or close) in both the app and in JSP
    Try simple date format in your JSP as well - what does that result in?
    Print the calendar object, and look for the difference.
    It might be in Locale, Timezone, or whether DST is set or not.
    Hope this helps,
    evnafets

  • Help! Dreamweaver keeps automatically 'putting' my template onto the server every time I save it.

    For some reason Dreamweaver keeps automatically 'putting' my template onto the server every time I save it, overwriting the template that was originally on there and I don't know why. It never used to do this and all my other sites work fine and don't have this problem... I don't want it to keep overwriting the files I have on the server... does anyone know how to stop it from doing this please? I would greatly appreciate any help anyone can give.
    If it helps, I'm using CS4.
    Thanks,
    Catherine.

    Thank you!
    For this particular website I only have one template. The website is up and running online, but I'm still working on it, trying to improve it and I'd like to preview before I upload it to the server and alter the other pages. I did have a backup of the template on the server as you said, but because I was experimenting with something in the local copy, the design changed quite a lot, and suddenly it was 'put' automatically (which was something it had never done before) resulting in a loss of the original template. Fortunately I ignored the prompt asking me to update the pages from this template, so the overall design of my live website has remained in tact. I pressed F12 as I always do and instead of taking me to my default browser for live preview, it 'put' the template onto the server. This is what I'd like to avoid doing again.
    Thank you for your response! I really appreciate your help.
    Catherine.

  • I have downloaded and deleted an album 3 times now because on the playback, every 30-60 secs. it jumps to another song on the album. I have never had this problem before. Thanks !

    I have downloaded and deleted an album 3 times now because on the playback, every 30-60 secs. it jumps to another song on the album. I have never had this problem before. Thanks !

    Try deleting and redownloading again, this time with simultaneous downloads disabled.
    While downloading select Downloads in the left-hand column and make sure Allow Simultaneous Downloads is unchecked.

  • I have just created my Apple ID on my MacBook Air and I wanted to activate my Face Time.  When signing in on Face Time, it keeps saying "The server encountered an error in processing registration. Try later" what to do?

    have just created my Apple ID on my MacBook Air and I wanted to activate my Face Time.  When signing in on Face Time, it keeps saying "The server encountered an error in processing registration. Try later". Can someone please help me?
    Thanks

    Hello,
    First make sure your Date & Time are correct, & whether AM or PM if using 12 hour clock.
    See these...
    http://support.apple.com/kb/TS3970?viewlocale=en_US
    http://conpartior.wordpress.com/2012/08/22/imessage-could-not-sign-in-imessage-t he-server-encountered-an-error-processing-registration-please-try-again-later-so lve/
    https://discussions.apple.com/thread/4314177?tstart=0

  • I have a problem with my Imessage at my macbook pro ,its says it can contact the server and i cant use it ,please solve me this problem

    i have a problem with my Imessage at my macbook pro ,its says it can contact the server and i cant use it ,please solve me this problem

    I am having the exact same problem with the iMessage on both my MacBook pro and my iphone4. It either says the username/password is incorrect or it can not contact the server. Facetime and iCloud works just fine with the same apple id and password. Somebody please help, I am beyond frustrated!

  • Problems connecting to iChat 4 on the server from a computer using iChat 3.

    Is this possible? I am an intern at my school and I am facing this problem. What is happening is we are testing the Leopard server on new iMac 20" and we set up an iChat server. We can log onto the iChat server from the server iMac. But when we attempt to access the 10.5 server from our computers using Tiger (10.4.10), it says that we can not connect to the server. We are using the same user name and config as on the 10.5 server Any ideas?
    This is the error message I receive when I attempt to connect to the iChat 4 10.5 server from a computer using Tiger (10.4.10):
    Could not connect to host "server name here"
    We currently have another iChat server set up on a server using Tiger and set up the 10.5 iChat server in the same way, yet it still will not work.

    I too ran into the problem of iChat on 10.4.x, along with Adium, not succeeding at connecting to the Jabber process on MOSXS v.10.5.1, but simply editing the /etc/jabberd/c2s.xml file to comment out the "gssapi" authentication fixed it up swell. In our case, Active Directory isn't an issue since we're an all-Mac shop.
    Here's the relevant section excerpted from the file:
    <!-- Available authentication mechanisms -->
    <mechanisms>
    <!-- These are the traditional Jabber authentication mechanisms.
    Comment out any that you don't want to be offered to clients.
    Note that if the auth/reg module does not support one of
    these mechanisms, then it will not be offered regardless of
    whether or not it is enabled here.
    Similarly, if <zerok/> is disabled, then zero-knowledge data
    will not be created when a user is registered. -->
    <traditional>
    <plain/>
    <cram-md5/>
    <!--
    <digest/>
    <zerok/>
    -->
    </traditional>
    <!-- SASL authentication mechanisms. Comment out any that you
    don't want to be offered to clients. Again, if the auth/reg
    module does not support one of these mechanisms, then it will
    not be offered. NOTE: Ted Dively commented out the "gssapi" authentication
    method on 11/28/2007 in order to allow Adium and older iChat
    clients to connect to this Jabber server. -->
    <sasl>
    <!-- <gssapi/> -->
    <!--
    <plain/>
    <digest-md5/>
    <anonymous/>
    -->
    </sasl>
    </mechanisms>

  • What size HDD do you need for Time Machine is it the size of iMac HDD?

    Ok, looking to buy iMac, to use Time machie do you need the same size HDD that is in your iMac? ie Im looking at getting the 250Gb iMac, so do I need a 250Gb external HDD to use time machine?
    I plan to also get a NAS drive so can time machine be used with this or do you need n external HDD attached direct to the iMac all the time to use time machine?
    cheers

    the loc-man wrote:
    so you can pick and choose what backup? eg Music, Pics, Docs, emails etc?
    Yes you can choose everything or just parts.
    does it compress stuff though to utilize the space better?
    No, look here for more detail. http://www.apple.com/macosx/features/timemachine.html
    its not like a ghost image?
    Not that I know of.
    so if the iMac had to be re-installed could you then reconnect the Time machine HDD and restore everything?
    You could insert the Leopard disk and instead of doing a new install you could restore directly from the Time Machine Back Up. This depends on if you do a full back up or just parts of your system. Either way it is easy to recover your system using Time Machine.
    Also if the external HDD is used for time machine is that all it can be used for? or can you also use it on other computers both Mac and PC?
    It is best if you use Time Machine on a partition by itself. Then the other partition can be used for normal stuff.

  • Why does Safari keep saying "it can't connect to the server" every time I try to access any sites?

    I have the latest safari update for os x, which was working perfectly fine up until 3 days ago. Everytime I would try to access any site, safari would tell me it couldn't connect to the server, and I would have to refresh the page at least 5-10 times until I can access the site. I checked my internet, and it seems to be running perfectly. I also tried using Chrome and it had no problems accessing sites, too, so I know it's not my internet. :/
    Is anyone else having the same problems?

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you boot, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • I have my time capsule   attach to the server.app but is lost now?

    when I configured my macmini server ask for attch the time capsule after a update, the TC dont apear in the server app, how ca I reconfigurate?

    When you say backed up.. does that mean in a backup using a software backup utility like MSbackup.. in which case the files will not be visible to any other application. Or did you just copy the files to the TC. What format are they in?? Did you copy a WIndows Itunes library to the TC that you are trying to use via the ipad or iphone? Generally that won't work as they need an itunes server not library running.
    Or what format are the files in? The iOS devices cannot even see files stored on the TC without an app like filebrowser. You then need an application that can read the file type. whatever that is.

Maybe you are looking for

  • Hex core efficiency in Bridge CS5 and Camera Raw 6.0

    Conclusion: Batch processing of files in Bridge CS5/Camera Raw 6.0 is limited by an unknown factor which I currently believe to be software design and/or software implementation.  While performance on a dual core would be more or less CPU bound, and

  • Access to the latest version of Oracle for Windows/Linux

    I teach an advanced course about databases and XML at the Royal Institute of Technology in Stockholm, Sweden. For that course I use Oracle as one of the platforms and the version available on the oracle website has certain annoying bugs that relate t

  • Duplicate Accounting Documents

    Dear ALL, 2 Accounting Documents were generated for 1 billing document,How this happens? Please advice me on how to correct this. TIA KOGI

  • Reassigned scratch disk--now, PS won't open!!!

    I have a Power Mac G4 (AGP) with two hard drives running Tiger. I installed CS4 and everything was fine until I started fiddling around in Photoshop and changed the scratch disk from disk 1 (10G start disk) to disk 2 (80G). All my applications are in

  • HDV out of sync

    I recently purchased a Canon XHA1 video camera. I use FCE HD 3.5 to edit video. I always seem to have to add, or subtract, 18-Frames from the video clip so it can sync properly with the audio. Is there something I'm doing wrong that FCE HD just does