Make sure objectoutputstream is open before objectinputstream

If I am not mistaken the objectoutputstream must be opened before the objectinputstream is for the connection to be made correctly. My task is to send an array from one computer to another through a socket, do some calculation then send back the calculated array. So I need to have communications both ways. I am running into problems with the connection not being made because I think the timing is off. On a small scale (2 computers) everything works fine, but for 1 computer trying to connect to multiple others (7) it isn't working.
Should I give up on object streams or is there a way to coordinate their openings? Thank you.
BTW-- the error message I get at the initial receiving computer is an IOException and the getMessage() returns null. This is the same error that i got on my small scale when I had objectinputstream opening before objectoutputstream.

icccapital wrote:
I don't know how reliable this source is, but here is the link where I had read that.
http://frequal.com/java/OpenObjectOutputStreamFirst.html
You seem to have misunderstood.that article. It doesn't not say that you have to construct the OOS that sends before you constuct the OIS at the other end that receives. Rather, it says that, on each end when you're doing bidirectional communication (which you are), you should construct that end's OOS before constructing its OIS. If you do this:
// client
ObjectInputStream ois = new ObjectInputStream(...);
ObjectOutputStream oos = new ObjectOutputStream(...);
// server
ObjectInputStream ois = new ObjectInputStream(...);
ObjectOutputStream oos = new ObjectOutputStream(...);then both sides are stuck in the OIS line because the OIS c'tor doesn't return until it reads something, but neither one can read because the other end--both other ends--can't write because it's can't get past the OIS. It's a form of deadlock.
So, theoretically, all you should have to do is switch the order and put OOS first on just one side, but to keep things simple I'd just do it on both:
// client
ObjectOutputStream oos = new ObjectOutputStream(...);
ObjectInputStream ois = new ObjectInputStream(...);
// server
ObjectOutputStream oos = new ObjectOutputStream(...);
ObjectInputStream ois = new ObjectInputStream(...);Again, remember, you don't have to worry about controlling the timing of the client and server relative to each other. It's just within each side, you want that side's OOS first.
Now, here's one thing I'm not sure of. I looked briefly at the code for both OIS and OOS, and OIS does indeed do a read in it's c'tor, and OOS does a write. I'm not sure why this would be any better. It looks to me like we'd now have both OOS lines blocking waiting to be able to write, so, contrary to what the article is saying (and contrary to what I just said above) it seems--at least at first glance--that we should do OOS first on one end and OIS first on the other. However, if there's buffering going on, then the OOS c'tor could just write its bytes to the buffer and return, without having to wait for them to actually be delivered.

Similar Messages

  • I need to make sure of some stuff before buying...

    Okay. Well. The main reason for me posting this topic is that I am planning on buying a MacBook Pro in a few weeks, and I was planning on buying a router to have my wireless internet, of course. However, with learning of the Airport Extreme, I was thinking buying this instead. However, I really need to know what I'm buying before doing so. I don't want to be disappointed in buying this.
    So, with that being said:
    1. With buying my mac, I will now have a computer to myself and so will my sister. We need to be able to be on the internet at the same time. She will be running a PC, a Windows XP, and I will have a MacBook Pro. I need to know if I will be able to run internet on both computers through the Airport Extreme Base Station and be able to ACCESS it at the same time. No interferences and such.
    2. I need to know if my internet WILL sync with this base station. I have a broadband connection right now, through Hughes Net. It has an Ethernet cable, but on the specifications of the Airport Extreme, it said that some ISPs may not sync with it. What can I do to make sure it'll work?
    3. With my Hughes Net, there is a thing that comes with it for everything to be plugged into. It has a few cables, the power cable, and then the ethernet cable. It is NOT router. But I dno't know what else to call it. Would I keep the ethernet cable in the back of this thing, and then plug it into the Airport Extreme Base Station, and then would it give internet to both computers?
    Please, I really need to know the answers to these questions before buying it. If you have anything else to add about the two computers with the internet, pleaseplease add. Thank you to anyone who replies.

    1. As long as you don't change anything in the Airport base station's configuration while it's in use it shouldn't be a problem. If you change anything configuration-wise it will need to reboot so anyone using it will lose connection for 20-30 seconds.
    2. Most ISPs will work, they would have to have a pretty strange setup to not work with Apple's base stations. I think they are just covering their butts in case of some really odd thing that keeps it from working.
    3. Your Cable/DLS modem (whichever you've got) is probably the box with everything plugged into it. You want to plug the ethernet cable coming out of it into the WAN port on your base station. It will either say WAN or some access points use an icon that is a bunch of lines arranged in a circular pattern (think of a typical children's drawing of a sun with the sun "beams" coming out as lines coming from the sun), whereas the Ethernet ports would be labeled as LAN or with an icon with two arrows. BTW when you plug the bas station into your Cable/DSL modem you'll want to power down the modem (just unplug the power from the wall) then plug in the base station with the base station turned on, then plug the modem back in. Sometimes these modems will "remember" the last device they were plugged into and will only work with that device until they get power cycled.

  • How to make sure that Safari opens in Full Screen

    When I open Safari in Mountain Lion it does not open in Full Screen.  I then get it there.  I close it.  I open it.  Does not open in full screen.  How to make it do so?

    you can download my fla project from here : http://www.megaupload.com/?d=V7QQ417Sthanks for help

  • How can i make sure ejb container starts before web server

    When starting the application server which one starts first?
    Our system requires ejb container to start first.
    Currently when i test it, the web container starts before ejb sometimes.
    Is there any way to force the ejb container to start up before the web container starts?

    What exactly is the dependency you have in your application? The Java EE spec does not
    impose any requirements on the order in which the different modules within an .ear are
    instantiated.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                               

  • Are there any ways to make sure FCPX saves the project before quitting?

    The other day when I was working on a project, Final Cut Pro did not save any changes I made for the last 3 hours. I lost all of my work. I understand that FCP is supposed to autosave  projects, but it didn't. Are there any ways to make sure that it saves before quitting? I am currently running the trial version 10.0.8, and I plan to upgrade to the full version, soon, provided there aren't too many bugs.

    It turns out it was a corrupted project. All other projects autosave before quitting, but that one always displays the same last modified time. I solved it by creating a brand new project.

  • Is it possible to have a window open for my library and the Itunes store so that I can toggle between the two?  I want to check my library before I purchase songs to make sure that I don't already own them.

    Is it possible to have a window open for my Itunes Library and Itunes store at the same time so that I can toggle back and forth between the two.  I want to check my library before I buy songs to make sure that I don't duplicate.
    Thanks!

    No.

  • Will Photoshop Elements 12 work with Mac OS X v10.9.4? Need to make sure before opening package... Thanks!

    Will Photoshop Elements 12 work with Mac OS X v10.9.4? I need to make sure before opening package... Thanks in advance!

    Yes, PSE versions 6 through 12 work in 10.9, although PSE 11 is a bit buggy. All other versions are fine, including PSE 12.

  • How do I make sure that all Firefox sessions are closed so I can download 6.0? Keep getting a dialogue box saying that only 1 can be open at a time. Only 1 IS open, and I need this update to meet a system requirement for an online class.

    Not sure what I can add to that. I actually shut down my Mac to make sure no sessions were open before I tried again. Help.

    Must be the "hang at exit" problem.<br /><br />
    #Stop the Firefox process:
    #*[http://kb.mozillazine.org/Kill_application Mozillazine - Kill application]
    #*Windows 7 users click [http://www.techrepublic.com/blog/window-on-windows/reap-the-benefits-of-windows-7s-task-manager/2576 here]
    #*Mac users: http://techheavy.com/2011/02/the-mac-task-manager/
    #Why Firefox may hang:
    #*[http://support.mozilla.com/en-US/kb/Firefox+hangs Firefox hangs] (see Hang at exit)
    #*[http://kb.mozillazine.org/Firefox_hangs Firefox hangs (Mozillazine)] (see Hang at exit and Closing Firefox properly)
    #*[https://support.mozilla.com/en-US/kb/Firefox+is+already+running+but+is+not+responding Firefox is already running but is not responding]
    #Use Firefox Safe Mode to find a problem with an Extension or Plugin:
    #*Don't check anything when entering Safe Mode, just continue
    #*If the problem does not occur in Safe Mode it is probably and Extension or Plugin causing the problem
    #*See:
    #**[[Safe Mode]] and [http://kb.mozillazine.org/Safe_Mode Safe Mode (Mozillazine)]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
    #**[http://support.mozilla.com/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • My Mac Book Pro has slowed to less than a crawl (possibly from a worm or virus).  How do I make sure it's running at peak efficiency before I complain to comcast

    My Mac Book Pro has slowed to less than a crawl (possibly from a worm or virus).  How do I make sure it's running at peak efficiency before I complain to comcast

    Please answer as many of the following questions as you can. You may already have answered some of them; in that case, there's no need to repeat the answers.
    Restart the router and the broadband device, if they're separate. Any change?
    Run Software Update and install all available updates for OS X or the computer's firmware. Any change?
    If possible, connect to the router with an Ethernet cable and turn off Wi-Fi. Any difference?
    Are any other devices on the network, and if so, are they the same?
    If you can connect to more than one network, are they all the same?
    Are all network applications affected, or only some? If only some, which ones?
    Is networking always the same, or is the problem intermittent?
    Disconnect all other devices from the network. Any change?
    If you're running a MacBook with the lid closed, open the lid. Any difference?
    Start up in safe mode and test. Any difference?
    Start up in Recovery mode. From the OS X Utilities screen, select Get Help Online. A clean copy of Safari will launch. No plugins, such as Flash, will be available. Any difference?
    If possible, turn off Bluetooth and disconnect any USB 3 devices. Any difference?

  • I have tried VERY unsuccessfully to install iphoto 9.2.3 update...it says it has successfully updated - then on opening says: iPhoto cannot be opened because of a problem. Check with the developer to make sure iPhoto works with this version of Mac OS X.

    I have tried VERY unsuccessfully to install the new iphoto 9.2.3 update.
    I have installed it several times both from the appstore and from Apple Support downloads...it says it has 'successfully updated' - then on opening iphoto, a dialogue box pops up and says:
    iPhoto cannot be opened because of a problem.
    Check with the developer to make sure iPhoto works with this version of Mac OS X. You may need to reinstall the application. Be sure to install any available updates for the application and Mac OS X.
    Click Report to see more detailed information and send a report to Apple.
    Insane...I have all my updates including Lion 10.7.3 why does APPLE KEEP SENDING BETAS AS A REAL PRODUCT?
    Does anyone know how to copy over a backup from a twinned drive Backup? What files etc.
    Thanks tons...

    Thanks Terence,
    I did get it working finally...and your last advice was what I needed.
    I am embarassed that I was an early adopter...SHOULD HAVE KNOWN BETTER and read the problems before creating some for myself.
    This was an excercise in frustration, because of the obtuse division between the appstore and Apple Support downloads... it was a bit of a circuitous route...strange that with all the security reciepts and tracking that Apple goes to to prevent piracy... which Steve by his own admission used to build Apple...
    Why aren't the server scripts smart enough to say…”HEY DUMMY you can't use this download because you purchased the last iPhoto upgrade from the appstore...and… DON'T WASTE YOUR TIME and precious data BUDGET downloading this gargantuan file which will eat 20% of your expensive 5Gb monthly data allotment!!!…and NOT WORK…only pretend to…and then foul your system….kill your productivity and turn your hair whiter…even worse than LION did.
    I am just so antagonized by the inept scripts in recent installations that don't do a diagnostic before allowing installation that is going to corrupt things...I had less effort and frustration when I ran my ATARI with a MAC emulator...rarely lost any productivity to nonsense.
    I AM TIRED OF BETAs dressed as products...designed and rushed out for Apple toys that once were tools of the creative trade...COREL...may still have a chance at a comeback if Apple keeps pumping out toys instead of the venerable tools we once adored as income enhancers.

  • Quick Time player cannon be opened because of a problem. Check with developer to make sure Quick Time player works with this version of Mac OS X

    "Quick Time Player cannot be opened because of a problem"  Futher noted - Check with developer to make sure Quick Time player works with this version of Mac OS X.  The player had been working fine on my iMac 24, even after upgrading to Lion. Now, nothing but this message. This involves Quick TIme Player version 10.0. Could upgrading to the 'Pro' version be worthwhile?  Can't find anything on support that comes close to answering this perplexing situation.
    Thanks,

    QuickTime Player 10.0, if that's what you have, is indeed too old for Lion which should have QuickTime Player 10.1. Check your system to see if perhaps you have two copies of QuickTime Player, something quite possible if you moved or renamed QuickTime Player before upgrading.
    Hope this helps.

  • HT1941 I have inadvertently changed a file permission setting. When opening Aperture I get the following; Aperture cannot access this library. To use this library make sure it's file permissions are set correctly. I am an old dude new to Mac OS. What up?

    I have inadvertently changed a file permission setting. When opening Aperture I get the following; "Aperture cannot access this library. To use this library make sure it's file permissions are set correctly". I am an old dude new to Mac OS. Looked in settings but have no idea how to allow file sharing to myself. I have been using Aperture actively for 6 weeks. I'm the only one using this Mac. What up?

    Back up all data now.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. If none of this is meaningful to you, you don't need to worry about it.
    Step 1
    If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. You can demote it back to standard status when this step has been completed.
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Drag or copy — do not type — the following line into the Terminal window, then press return:
    sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; sudo chown -R $UID:20 ~ $_ ; chmod -R -N ~ $_ 2> /dev/null
    Be sure to select the whole line by triple-clicking anywhere in it. You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up. You don't need to post the warning. If you don’t have a login password, you’ll need to set one before you can run the command.
    The command will take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear, then quit Terminal.
    Step 2
    Boot into Recovery by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the OS X Utilities screen appears, select Utilities ▹ Terminal from the menu bar. A text window opens.
    In the Terminal window, type this:
    resetpassword
    That's one word with no spaces. Then press return. A Reset Password window opens. You’re not going to reset a password.
    Select your boot volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select  ▹ Restart from the menu bar.

  • Is it secure to have the pulic open a resource guide in Adobe Reader?  Or is there a way to make sure anyone using the link to the guide is secure?

    Is it secure to have the public open a resource guide in an Adobe Reader PDF?  Or is there a way to make sure anyone using the link to the guide is protected?
    Not sure how to find an answer to this.
    Thanks, GM

    I am trying to post a 123 page resource guide online for the public to access through the website of a non profit.  The guide has a lot of web links for to use for more information.  But there have been clickability issues when using some browsers to download the PDF and so I would prefer to suggest that they try to download the resource into Adobe Reader before using.  I want to make sure that this would securely safe for readers and users.
    Sorry I was not clear in my original question and thank you for your kind attention.
    Thank you again,
    GM

  • Greeting,  I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the in

    Greeting,
    I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the information on it so could you tell me what kind of encryption will be used or is there any way to recover the information?
    Thanks!

    I think FileVault is used to encryp internal hard drive but I wanna encrypt an external hard drive with Mac OS Extended Journaled Encrypted which is completely different!

  • An update tries to run, but an error message stating "The update could not be installed. Please make sure there are no other copies of Firefox running on your computer, and then restart Firefox to try again." I can't open Firefox

    I click on Firefox and it says that Firefox is installing your updates and will start in a few minutes. Then I get "The update could not be installed. Please make sure there are no other copies of Firefox running on your computer, and then restart Firefox to try again." this cycle never ends. Do I need to deinstall Firefox and re-install? If I do that, do i lose all of my bookmarks, etc?

    See http://kb.mozillazine.org/Software_Update (Software Update not working properly)
    Remove the files in the updates and updates\0 folder:
    *C:\Documents and Settings\&lt;user&gt;\Local Settings\Application Data\Mozilla\Firefox\Mozilla Firefox\updates
    *(%USERPROFILE%\Local Settings\Application Data\Mozilla\Firefox\Mozilla Firefox\updates)
    *C:\Program Files\Mozilla Firefox\updates
    *Do a clean reinstall and download a fresh Firefox copy from http://www.mozilla.com/firefox/all.html and save the file to the desktop.
    *Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer. Do not remove personal data when uninstalling.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    You can skip the step to create a new profile, that is not necessary for this issue.
    See http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

Maybe you are looking for

  • USB Device Not Recognized (&IPOD WILL NOT TURN ON)

    I have had an iPod Shuffle G2 for 6 months now with no problems until today. It went flat when I was at my friends place so when I got back to my mums I plugged it into my laptop and it told me "USB Device Not Recognized One of the USB devices attach

  • Extracting data from clobs

    Hi, I want to get the first line from a comments field. The data type is set to clob. I use the below section to get the data from the first line Replace(dbms_lob.substr(comments,instr(comments,chr(10),1),1), Chr(10), '' ) from The issue I have is it

  • Multiple document use of field.buttonSetIcon(...) is failing

    We're trying to store a set of icons in a pdf document that can be shared by all the attached pdf documents.  The result of this would be then when we are in one of the attached documents (call it the child), we can read the icon from the parent docu

  • Similar to HAL

    Hi, In the past I used to create exe (for building hieararchy in sql, update dimensions, refresh essbase, load data and run calc scripts) using HAL and scheduled it. Can I do all of the above with any other tool? Thanks

  • Can't print or save pdf files in saferi 6 running ml

    cant save or print pdf files in safari 6 after upgrading to mountain lion