How to get server data without reading from the socket stream?

My socket client checks for server messages through
            while (isRunning) { //listen for server events
                try {
                        Object o = readObject(socket); //wait for server message
                            tellListeners(socket, o);
                } catch (Exception e) {
                    System.err.println("ERROR SocketClient: "+e);
                    e.printStackTrace();
                try { sleep(1000); } catch (InterruptedException ie) { /* ignore */ }
            }//next client connectionwith readObject() being
    public Object readObject(Socket socket) throws ClassNotFoundException, IOException {
        Object result = null;
System.out.println("readObject("+socket+") ...");
        if (socket != null && socket.isConnected()) {
//            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
            ObjectInputStream ois = new ObjectInputStream(new DataInputStream(socket.getInputStream()));
            try {
                result = ois.readObject();
            } finally {
//                socket.shutdownInput(); //closing of ois also closes socket!
    //            try { ois.close(); } catch (IOException ioe) { /* ignore */ }
        return result;
    }//readObject()Why does ois.readObject() block? I get problems with this as the main while loop (above) calls readObject() as it's the only way to get server messages. But if i want to implement a synchronous call in adition to this asynchronous architecture (call listeners), the readObject() call of the synchronous method comes to late as readObject() call of the main loop got called before and therefore also gets the result of the (later) synchronous call.
I tried fideling around with some state variables, but that's ugly and probably not thread safe. I'm looking for another solution to check messages from the server without reading data from the stream. is this possible?

A quick fix:
- Add a response code at the beginning of each message returned from the server indicating if the message is a synchronous response or a callback (asynch);
- Read all messages returned from the server in one thread and copy callback messages in a calback message queue and the synch responses in an synch responses queue;
- Modify your synchronous invocation to retrieve the response from the responses queue instead from the socket. Read the callback messages from the corresponding queue instead from the socket.
Also take a look at my website. I'm implementing an upgraded version of this idea.
Catalin Merfu
High Performance Java Networking
http://www.accendia.com

Similar Messages

  • I broke my iPhone 5 now using a 4 but don't know if or how to get my photos ect..from the 5 to the 4.can I do this and how plse help

    I broke my iPhone 5 now using a 4 but don't know if or how to get my photos ect..from the 5 to the 4.can I do this and how plse help

    Restore the backup of your iPhone 5 to your iPhone 4.  It will contain your camera roll photos. 
    To do this, first make sure the iPhone 4 is running the same or higher version of iOS as your iPhone 5 was.  If it isn't, you'll need to update it first.  Then, to restore the iCloud backup, you'll have to begin by erasing the iPhone 4.  If you have any newer data on the iPhone 4 that is not contained in the iPhone 5 backup, you'll need to save that first.  When you're ready, go to Settings>General>Reset, tap Erase All Content and Settings, then go through the set screens on the iPhone 4 and when given the option, choose Restore from iCloud backup and follow the prompt, choosing the backup of your iPhone 5 to restore to.  Be sure it is connected to wifi and your charger as it is restoring the backup.

  • How to get customer number and name from the SD document

    Hi All,
    Can you please let me know how to get Customer Number and Name from the SD Document?
    Thanks a lot....
    Anil

    Hi,
    It will be displayed in the SD (BIlling document) itself,  you clikc on the VF03. The customer name and number will also appear in the SO document also Tcode VA03
    regards,
    radhika
    Edited by: kolipara radhika on Jul 10, 2009 5:32 AM

  • Getting error Can't read from the source or disk when moving documents from one folder to another folder in the library

    Hi,
    When we try to move documents from one folder to another folder in the document library using "Open with explorer" getting beloe error.
         Can read from the source file or disk.
        The user having below permission for the Library as well as site.
    Fullcontrol,Limited access--->Given directly
    Read,Limited access--->Givin through the all Test grp
    Contribute,Limited Access-->given through test members grp
    Read,Limited access---> givin through The group grp
    Could you please help me anyone....
    Thanks

    Hi Reddy,
    If you are moving files in two libraries in different sites, then the error will occur and it is by design that there are limitations on the DAV move commands that the DAV client is respecting.
    https://social.msdn.microsoft.com/Forums/en-US/6245f332-c609-4a7b-8e00-c8b5e46f7759/cant-move-files-using-windows-explorer-cant-read-from-source?forum=sharepointgeneral
    If you are moving files in the same library, I recommend you to use Wireshark to reveal the error message and enable IIS
    Trace Logging for Failed Requests to examine the IIS log file for troubleshooting.
    https://social.msdn.microsoft.com/Forums/en-US/47cd569d-98f2-4cca-b78e-fd178c097285/cant-read-from-the-source-file-or-disk?forum=sharepointgeneralprevious
    To narrow down the issue scope, I recommend you to test with another library and see if the copy in explorer can work.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • How to hide duplicate photos that origins from the photo stream and imported photos?

    Hi,
    I are using my camera both with an IPad (through SD-card reader) and directly to my iMac.
    I want to keep the full photo archive on the iMac.
    Now the problem, that I encounter, is that if I use the iPad to look at the photos, those photos will be transfered to the photo-stream.
    Then later when I import all my photos from the camera to the i Mac, those photos that I happened to import to the iPad will show up as duplicate in iPhoto.
    Of course I only want one copy of a photo regardless if they arrive from the photo-stream or through a direct import to my iMac.
    Is there a way to fix this problem or is it simply a bug?
    I think it would be rather easy for the iPhoto software to detect duplicates and hide them.

    You can use one of these applications to identify and remove duplicate photos from an iPhoto Library:
    iPhoto Library Manager - $29.95
    Duplicate Annihilator - $7.95 - only app able to detect duplicate thumbnail files or faces files when an iPhoto 8 or earlier library has been imported into another.
    PhotoSweeper - $9.95 - This app can search by comparing the image's bitmaps or histograms thus finding duplicates with different file names and dates.
    DeCloner - $19.95 - can find dupicates in iPhoto Libraries or in folders on the HD.
    DupliFinder - $7 - shows which events the photos are in.
    iPhoto AppleScript to Remove Duplicates - Free
    Some users have reported that PhotoSweeper did the best in finding all of the dups in their library: i photo has duplicated many photos, how...: Apple Support Communities.
    If you have an iPhone and have it set to keep the normal photo when shooting HDR photos the two image files that are created will be duplicates in a manner of speaking (same image) but the only duplicate finder app that detected the iPhone HDR and normal photos as being duplicates was PhotoSweeper.  None of the other apps detected those two files as being duplicates as they look for file name as well as other attributes and the two files from the iPhone have diffferent file names.
    iPLM, however, is the best all around iPhoto utility as it can do so much more than just find duplicates.  IMO it's a must have tool if using iPhoto.
    OT

  • How to remove noisy data points read from a text file

    Reading data measurements taken in from a txt file.  How do I get rid of noise aside from going into the text file and deciding point by point what to delete.

    Well going in point by point and deleting is certainly one way of going about it. Of course that would defeat the entire purpose of having this great programming enviroment that is capable of doing that kind of thing for us.
    Is your text file small enough to upload? Obviously you know what the criteria are for judging whether or not a data point is acceptable so it should be simple enough to program. Give us a bit more information and I can assure you there will be a race between LabVIEW experts to see who can post the cleanest, simplest, and fastest piece of code that will do what you need. My wager is on altenbach, but there are a few others here that are almost as impressive.

  • How to get server hostname and port from web form

    Hi All,
    I need to find out server hostname and port number
    from 9i form.
    That is if the form was called via:
    http://myserver.com:1234/f90servlet?form=test,
    i would like to call some
    GET_XXX_PROPERTY(SERVER_HOSTNAME) that would return
    myserver.com
    and
    GET_XXX_PROPERTY(SERVER_PORT) that would return
    1234
    or alternatively
    GET_XXX_PROPERTY(SERVER_URL) that would return
    complete URL, so that i can parse it myself.
    Does anything like this exist? If not,would be
    possible to get that information from any Java
    function via java importer?
    BR,
    Robert
    BR,
    Robert

    Robert,
    I'd add the code as a Java Bean in Forms and get this information from the Forms request URL.
    Add the following bean to a Canvas and make it a size of 1x1 pixel so taht it appears hidden
    import java.applet.Applet;
    import java.net.URL;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    public class FrmRequestInfo extends VBean
    public static final ID pGetPort = ID.registerProperty("GET_PORT");
    public static final ID pGetHost = ID.registerProperty("GET_HOST");
    public static final ID pGetProtocol = ID.registerProperty("GET_PROTOCOL");
    private String _host;
    private String _port;
    private String _protocol;
    private URL FormsURL;
    Applet m_applet;
    /*Forms settings*/
    IHandler m_handler;
    public FrmRequestInfo()
    public final void init (IHandler handler)
    super.init(handler);
    m_handler = handler;
    // get the forms applet handler
    m_applet = m_handler.getApplet();
    // initialize cookie domain to the same domain that runs Forms
    // Services
    FormsURL = m_applet.getDocumentBase();
    _host = FormsURL.getHost();
    _port = new Integer(FormsURL.getPort()).toString();
    _protocol = FormsURL.getProtocol();
    public Object getProperty(ID p0)
    if (p0 == pGetHost)
    return _host;
    else if (p0 == pGetPort)
    return _port;
    else if (p0 == pGetProtocol)
    return _protocol;
    else
    return super.getProperty(p0);
    To get the port number you call
    VarcharVariable_Port := get_custom_property('beanblock.beanname',1,'GET_PORT');
    for the hostname
    VarcharVariable_Host:= get_custom_property('beanblock.beanname',1,'GET_HOST');
    Frank
    Ps.: just wrote the bean on the fly, without testing - but I am positive that it works as similar functionality works for me in other beans.

  • Get server date, or day from server

    Hey guys,
    Just wondering how I can retrieve info from the server, such as day of the week for a gym timetable panel.
    Basically I want to have an unordered show or hide different list items depending on the day of the week. So, if its Monday, a particular class will be shown while the rest are hidden for example.
    Will I have to revert to javascript to solve this issue or are there generic tags I can use to get from the server?
    Thank you

    Hey there,
    (nice user name)
    No sever date or time.. Someone may post and say "Your wrong liam, there is this module.. {module_today}" But what they will not realise is that just renders javascript to get the current day, which of course is fetching the clients date info

  • How to get multipe data set values from Decision Table.

    Hi All,
    I need to use SAP BRM for one of the scenario where based one some Code Group I need to get a set of questions and for each question a set of possible answers.
    The structure of Decision Table will be like below :
    Table 1 : To get set of questions based on Project Code
    Input                   Output           Output
    Project Code
    Question Id
    Question Description
    Table 2 : To get set of answers based on question
    Input                   Output            Output
    Question ID
    Answer Id
    Answer Description
    I already searched in forum to get the multiple values based on some input and that works fine for a single field with multiple outcome.
    Handling Selective Multiple Actions in  SAP Business Rules Management System
    In my scenario I need to get a set of Id and description as multiple outcome.
    Can anyone please let me know how this can be achieved in BRM.
    Thanks in advance
    Ravindra

    Create an XSD in the BRM project with the desired data structure and import the XSD alias in the 'Project Resources'. Add this XSD alias as input/output of the decision table.
    Refer this:
    Creating a Simple BRM Ruleset in 30 Easy Steps using NWDS 7.3 (Flow Ruleset with a Decision Table)

  • How to get server date and time using java code

    Hi,
    I'm new to java. I have one doubt about getting date and time of the server. can anyone give some sample code to get that.
    thanks in regards
    Gopi.

    you need 2 things
    1. something on the application server which exposes the servers time/date
    2. something on the client which makes use of your time service
    for instance, you could write a ServerTimeServlet that clients can call to get the time according to the server. or, if you've got a database in the server, often database software will provide a Time procedure or similar that does this, so you can use a simple SQL query to get the latest time

  • How to get a Previously purchased app  from the App Store from a different account on the same computer?

    Recently had to replace my hard drive and some info has gone missing.  An App from the App Store for one.  How can I get it back now that I have a new account?  It wont let me sign on with the old one anymore.

    There's no need to create a new Apple ID just because the hard drive was replaced.
    Apps can only be re downloaded using the same Apple ID they were purchased with originally.
    You will have to re purchase the app using the new Apple ID.

  • How to get ringtones on my iphone4 from the music on my phone

    I make the ringtones and have to email them to myself but still don't know how to get them on my phone to be able to use.

    In case you don't know, ringtones use a different format then songs.  When you say "I make the ringtones", you need to have used an appropriate utility to do that.
    Assuming you did, then place those ringtones into the "Tones" section on iTunes on your computer, and sync your iPhone using iTunes, making sure you have the right rule set up so your tones get synced.

  • How to get my usernames to appear from the drop down box then password automatically put in?

    =( ugh...
    I used to have my settings where it remembered my user name from the drop down box - so I would just type the first letter of my user name and a drop down box would appear and I could just click on my user name for that particular site and my password would automatically fill in...
    I changed something the other night and can't remember what the heck I did... now it won't remember ANY user name OR password or like on face book it has my user name and password there automatically when I open up the log in face book page.
    So I would like to know if anyone knows what needs to be clicked and unclicked to make it so:
    I start typing my user name and the drop down box appears with user names and then my password automatically fills.. I DO NOT want all my user names and passwords already IN the forms when I first open the website... but for me to actually type in a letter and then it fills it... like it used to =(
    /cry
    why do I touch stuff?
    Anyway I hope someone can help me because I am going nuts trying to figure it out and think I'm goofing things up even more =/
    I have firefix 3.6.10

    Does this help?
    * http://kb.mozillazine.org/Password_only_filled_after_entering_user_name
    * Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Automatically start Firefox in a private browsing session"

  • How to get location data when uploading from DSLR?

    I have read that you can't add or edit location data when files are added to Photos in the new Yosemite version.  But does the location still get added when you upload via a wireless connection like on the iPad?
    If not, is there a workaround?I have ended up with thousands of photos on the iMac with no location data as a result of the upgrade.  I don't want to make the problem worse. 
    Any help or advice appreciated.

    I'm not exacting sure what the difference between tagging and geotagging is.  I do know that at present on my ipad (and I haven't upgraded it from IOS7 yet), if I import my DSLR photos to the ipad, when in a wifi environment, it adds the location to the photos where they were uploaded.  Without wifi, no location gets added. I actually haven't figured out a way to add location data to the photos using the ipad, is there a way?  I have always been advised before to use my mac to do that, which is no longer possible in Yosemite as far as I can tell. 

  • How to get Solaris 10 to boot from the CLI instead of the GUI?

    I tried searching on the site but was unable to get useful information from setting up Solaris such that it boots to command prompt instead of the GUI. Any help or suggestions would be appreciated.

    This will also work if you're running out-of-the box Solaris 10:
    svcadm disable graphical-login/cde-login:defaultThe problem with doing it that way is you then can't use your Solaris host to run SunRay thin clients. If you need to use the box as a SunRay server, you'll have to remove the reference to the :0 display somewhere in /etc/dt/config/Xconfig, IIRC.

Maybe you are looking for

  • How can I find tables for LOCK in ko02 ?

    Hi everbody . I want to learn a table . in the ko02 screen  EDIT --> LOCK --> SET . but I dont know this table field. in the set locked to data which table we use =? thanks reply.

  • Need Help With Drivers for 488ca

    Hi I'm having nothing buy trouble I have a designjet 488ca and for the life of me can't down lode the soft ware they no longer make the CD and this thing is just keep going around with the same old crap I would be glad to pay for the CD if they just

  • Editing Payload in SXMB_MONI

    Hi All, Is this possible to edit payload in SXMB_MONI. I have already the following url which talks about editing payload from RWB - > Message monitoring. https://www.sdn.sap.com/irj/scn/wiki?path=%3fpath=/display/xi/whole%252bpayload%252bto%252ba%25

  • JSF 1.2 web.xml configuration parameters

    Actually, I know these JSF 1.2 web.xml configuration parameters: javax.faces.CONFIG_FILES javax.faces.DEFAULT_SUFFIX javax.faces.LIFECYCLE_ID javax.faces.STATE_SAVING_METHOD Are there any more available? (I have to study its performance implications

  • ADI SoundMAX Audio driver latest update

    Hi Everybody: TVSU shows this ADI SoundMAX Audio driver (version 5.10.01.6380-0005 released 2009/02/18) as the latest for my system. Actual version installed is 5.10.01.6380-0002 which I downloaded from the matrix in April when TVSU still wasn't avai