How to solve the exception with socket and PrintWriter constructor

I am working on a socket communication program and everything works fine on my computer until my boss moved my code to his computer. The following is the client code.
The client program terminate with exception "Couldn't get I/O for the connection to local host." I have no idea how to solve the problem because there is no way out if the two statements (socket constructor and PrintWriter) fail.
/*the program shall close connections and exit if the user clicks 'e'.*/
public class LocalClient extends JPanel implements KeyListener {
Socket localSocket = null;
PrintWriter out = null;
BufferedReader in = null;
char fromServer = ' ';
public LocalClient() {
try {
localSocket = new Socket("a029243.cs.uregina.ca", 4444);
out = new PrintWriter(localSocket.getOutputStream(), true);
} catch (UnknownHostException e) {
System.err.println("Don't know about local host.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to
local host.");
System.exit(1);
addKeyListener(this);
}//end of constructor
/*the component needs to be focused in order to respond to user input */
public boolean isFocusTraversable() {return true;}
public void keyPressed(KeyEvent evt) {
public void keyReleased (KeyEvent evt) {
public void keyTyped(KeyEvent evt) {
System.out.println("key typed is called ");
char fromClient=evt.getKeyChar();
if (fromClient!= ' ') {
if (fromClient=='e')
try {
out.close();
localSocket.close();
System.exit(1);
} catch (IOException e)
{System.out.println("connection closed");}
else {
System.out.println("Client: " +
fromClient);
out.println(fromClient);
out.flush();}
public static void main(String[] args) throws IOException {
JFrame frame1=new JFrame();
Container contentPane=frame1.getContentPane();
LocalClient lc = new LocalClient();
contentPane.add(lc);
frame1.pack();
frame1.setSize(50,50);
frame1.setVisible(true);
}//end of main
} //end of class

Add e.printStackTrace() or System.out.println(e) to the catch block of the IOException. The IOException has a message about what went wrong.

Similar Messages

  • I have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending

    i have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending the mail.
    Also the mail is acting very funny by not getting the rules work in a proper method.  Is ther a software to repair mail.

    i did both of them, but still the while sending the mail the diolog box is not showing up and also the spelling and grammer does not do the spelling check. 
    This problem just started for about 3 to 4 days now.  earlier it was working normally.

  • How to solve the problem with time difference?

    Hi,
    I work in India with time difference about 12 hours faster than American time.
    I put a validation in my application as follows:
    IF :P2_FINISH_DATE > SYSDATE THEN
    return false;
    else
    return true;
    end if;
    Today (13-Mar-09) at 9:30 am according to my system, I entered 13-Mar-09 as FINISH_DATE.
    But it returned false with an error message: "Finish date cannot be greater than system date."
    I changed my system time as 13-Mar-09, 9:30 pm. Then it accepted 13-Mar-09 as FINISH_DATE.
    How can I solve this issue.
    Would appreciate your help.
    Thanks,
    Guy

    Hi Arie,
    Thanks for the code.
    Your code works perfect in SQL Commands.
    But I don't know how to use the code in my application.
    Would appreciate if you can help me know the followings:
    - How to define two application processes -- before header and after submit (before any processing) – with the proper alter session statement.
    - How to use the APEX VPD field to do the same.
    FYI, I use the following codes:
    - For file upload
    If (:p2_SUBMIT_FILE is not null) then
    insert into PM_DOCUMENT (id, name, blob_content, mime_type, PROJECT_NAME, SUBMIT_TIME, SUBMITTED_BY)
    select id, :p2_SUBMIT_FILE, blob_content, mime_type, :P2_NAME, SYSDATE , :P2_UPDATED_BY
    from apex_application_files
    where NAME = :p2_SUBMIT_FILE;
    Delete from apex_application_files where name = :p2_SUBMIT_FILE;
    end if;
    - For Data entry validation
    IF :P2_START_DATE > :P2_FINISH_DATE
    OR :P2_START_DATE > :P2_TARGET_DATE
    OR :P2_FINISH_DATE > SYSDATE THEN
    return false;
    else
    return true;
    end if;
    Thanks,
    Guy

  • How far is the compatibility with PowerPoint and Keynote '09?

    Hello everyone
    I love making presentations and strangely while I'm an Apple fan the only thing I still didn't convert to is iWork
    Keynote is the best presentation tool I ever saw. The problem is with playing the presentations in college or anywhere else.
    I know that keynote is compatible with PowerPoint, but how far?
    Will the beautiful transitions and animations on keynote work on PowerPoint? Alongside with the beautiful graphics, charts and backgrounds?
    Thanks

    I would say the compatibility is "just good enough". If you NEED to use it you will, but you don't want to ever NEED it.
    You shoud think of the compatibility as being like trying to playback high resolution, color, widescreen, Dolby stereo content on a small black and white mono tv. There are some things that old telly just won't be capable of. Sure, you can see the motion and hear something, but you're ultimately limited by what you use to PLAYBACK the content, not what you used to CREATE it.
    Because Keynote has features that PowerPoint doesn't, PowerPoint will never be able to playback exactly what you see in Keynote. The reverse is true as well.

  • How do solve the compatibility between windows and itunes?

    I can not sign out of itunes from the library.. I click  store tab in the library the sign out. the tab turns black and freezes up. I have to shut down and restart .

    A picture would be very helpful in demonstrating what you are having trouble with.
    Lacking that, I will guess.
    VI Properties >>> Windows Size
    lets you define the minimum size of a FP window.
    Well that's my guess!
    Did I win?
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to create the document with originals and checkin that document

    I am using this 2 bapi for creating DMS ,
    BAPI_DOCUMENT_CREATE2
    BAPI_TRANSACTION_COMMIT
    BAPI_DOCUMENT_CHECKIN2
    BAPI_TRANSACTION_COMMIT
    at last we want to c in DRAO table the created doc no should be updated here.
    But it not updating.how can i update in the table..
    Please tell via code..

    How do you call BAPI_DOCUMENT_CREATE2?
    I just tried with the example given in the documentation and with a little adjustment I created a document with an original which appears in the DMS_DOC_FILES table.
      DATA: ls_doc    LIKE bapi_doc_draw2,
            ls_return LIKE bapiret2.
      DATA: lf_doctype    LIKE bapi_doc_draw2-documenttype,
            lf_docnumber  LIKE bapi_doc_draw2-documentnumber,
            lf_docpart    LIKE bapi_doc_draw2-documentpart,
            lf_docversion LIKE bapi_doc_draw2-documentversion.
      DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
            lt_drat  LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE.
      ls_doc-documenttype    = 'Z01'.
      ls_doc-documentversion = '01'.
      ls_doc-documentpart    = '000'.
      ls_doc-statusextern   = 'DR'.
      ls_doc-laboratory     = '001'.
      REFRESH lt_files.
      CLEAR lt_files.
      lt_files-docfile      = 'c:\BP\test.docx'.
      APPEND lt_files.
      CLEAR lt_drat.
      REFRESH lt_drat.
      lt_drat-language    = 'EN'.
      lt_drat-description = 'Info Rec Description'.
      APPEND lt_drat.
      CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
            EXPORTING: documentdata         = ls_doc
            IMPORTING: documenttype         = lf_doctype
                       documentnumber       = lf_docnumber
                       documentpart         = lf_docpart
                       documentversion      = lf_docversion
                       return               = ls_return
           TABLES: documentdescriptions = lt_drat
                   documentfiles        = lt_files.
      IF ls_return-type CA 'EA'.
        ROLLBACK WORK.
        MESSAGE ID '26' TYPE 'I' NUMBER '000'
                WITH ls_return-message.
      ELSE.
        COMMIT WORK.
      ENDIF.
    Best Regards,
    Martin

  • Downloading and installing the iOS5.0.1 Following problems occured: with my iPhone 4s: Phone calls are dropping out in UAE, how to solve the problem?

    Downloading and installing the iOS5.0.1 Following problems occured: with my iPhone 4s: Phone calls are dropping out in UAE, how to solve the problem?

    You're not speaking to Apple on in this forum, nor will someone from Apple see this post.   We are just users like you and I.
    Have you tried to restore or reset your phone?
    Or contact your carrier in re: to your sim card

  • How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    I hate "J term"
    OK I love the learning the students get.   And, I like helping them out!  But, as a former man who's got the varicose viens to prove he's spent time "behind the podium" (yeah, "behind the podium" puts 'em to sleep- songs and dances for the young'uns) come on! USE the tools you teach!
    Instructors invited to engage in the forums
    Jeff

  • How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1. The problem is that after inputing the formatting gets lost. Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1.
    The problem is that after inputing the formatting gets lost.
    Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    * Clipboard not working -> [http://kb.mozillazine.org/Clipboard_not_working]
    * Rich Text Editing -> [http://kb.mozillazine.org/Rich_text_editing]
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    Check and tell if its working.
    Might not be related to your problem but some of your Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • A friend created 3 accounts on his iPhone 5 but forgot the passwords. He can't reset the password as yahoo address is no longer valid. Erasing the phone doesn't solve the issue. How to register the phone with Apple?

    A computer illiterate friend created 3 accounts on his iPhone 5 but forgot the passwords. He can't reset the password as his yahoo address is no longer valid. Erasing the phone doesn't solve the issue as the Apple server identifies the hardware as registered. How to register the phone with Apple?
    I helped him create a new email address and new iCloud account on my Mac but when we try to register the phone with Apple it says: Maximim accounts limit reached for this device. How can he register the phone? I read different threads and found out that only Apple care can do that. We're in Romania and don't know where to call. Any suggestions on how we fix this?

    When I checked the support site for Romania, you apparently don't have an Apple Care contact center.  You "may" try calling the US Apple care number to verify the account and have the password reset sent to a different email address.  800-694-7466

  • Hello  Simple problem - don,t know how to solve it.  With Premiere CC when I try to do a selection (click... drag... release the click) very often it stop way before the end of the move I'm swinging the Magic Mouse. I taught that the mouse clicking was de

    Hello
    Simple problem - don,t know how to solve it.
    With Premiere CC when I try to do a selection (click... drag... release the click) very often it stop way before the end of the move I'm swinging the Magic Mouse. I taught that the mouse clicking was defective and went to get a new Magic Mouse after lots of frustration. Today, I have an edit to do it it does the SAME thing !!
    I was like ????#$%?&*(???
    Opened all the lights and taught I've trow the new mouse to the garbage and was using the defective mouse again... no !! - ??
    Actually, the bran new mouse is doing the same thing. What I understand after investigating on the motion and watching carefully my fingers !! -  is that when I click I have to keep my finger at the EXACT same place on the mouse... drag and release and it's fine. If I click by pushing on the mouse and my finder is moving of a 1/32th of a millimeter, it will release and my selection will be to redo. You can understand my frustration ! - 75$ later... same problem, but I know that if I click with about 5 pounds of pressure and trying to pass my finger through the plastic of the mouse, it you stay steady and make it !
    The problem is that scrolling is enable while clicking and it bugs.
    How to disable it ??
    Simple question - can't find the answer !

    Helllooo !?
    sorry but the Magic Mouse is just useless with the new Adobe Premiere CC and since I'm not the only one but can't find answer this is really disappointing. This mouse is just fantastic and now I have to swap from a USB mouse to the Magic Mouse every times I do some editing. My USB mouse if hurting my hand somehow and I want to got back to the Magic Mouse asap. Please - for sure there is a simple solution !
    Thanks !!

  • I'm getting kernel panics each day as I shut down, the message of restarting by holding down the power button appears on the screen - it began about a month ago and. Do you have any ideas of how to solve the problem?

    I'm getting kernel panics each day as I shut down, the message of restarting by holding down the power button appears on the screen - it began about a month ago and. Do you have any ideas of how to solve the problem? I've copied the logs that I found for each kernel panic that still have the message logged. Please help if you can, I have read some of the other comments and perhaps it has something to do with my anti-virus software being on at start up. I have copied the log here. Any advice will be welcome.
    Interval Since Last Panic Report:  665204 sec
    Panics Since Last Report:          8
    Anonymous UUID: D6DCC90D-A5CA-4BBE-A435-3E64A512A51B
    Sat May 26 07:23:05 2012
    panic(cpu 3 caller 0xffffff80002b4f36): trying to interlock destroyed mutex (0xffffff801a489be0)
    Backtrace (CPU 3), Frame : Return Address
    0xffffff8160313b00 : 0xffffff8000220792
    0xffffff8160313b80 : 0xffffff80002b4f36
    0xffffff8160313b90 : 0xffffff8000227e68
    0xffffff8160313bd0 : 0xffffff7f80d14250
    0xffffff8160313c20 : 0xffffff7f80d14f73
    0xffffff8160313cc0 : 0xffffff800059a237
    0xffffff8160313d00 : 0xffffff8000586cbf
    0xffffff8160313d20 : 0xffffff800057e6e3
    0xffffff8160313df0 : 0xffffff800057ed06
    0xffffff8160313e20 : 0xffffff8000583c52
    0xffffff8160313e70 : 0xffffff8000583d05
    0xffffff8160313e90 : 0xffffff80005358b4
    0xffffff8160313ef0 : 0xffffff80005367c3
    0xffffff8160313f30 : 0xffffff8000536897
    0xffffff8160313f60 : 0xffffff80005ccfe8
    0xffffff8160313fb0 : 0xffffff80002da5e9
          Kernel Extensions in backtrace:
    com.intego.iokit.VBX6NKE(1.0)[211D5E46-3E43-C5DC-9C6A-8C3FFF0F4493]@0xffffff7f8 0d11000->0xffffff7f80d1bfff
    dependency: com.apple.iokit.IONetworkingFamily(2.1)[2FCC16E1-34AB-3908-98BD-CCBFA56FFDCE]@0 xffffff7f809b7000
    BSD process name corresponding to current thread: iStatLocalDaemon
    Mac OS version:
    11E53
    Kernel version:
    Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64
    Kernel UUID: A8ED611D-FB0F-3729-8392-E7A32C5E7D74
    System model name: iMac11,2 (Mac-F2238AC8)
    System uptime in nanoseconds: 69777074610
    last loaded kext at 58265763561: com.intego.iokit.VBX6NKE            1 (addr 0xffffff7f80d11000, size 45056)
    loaded kexts:
    com.intego.iokit.VBX6NKE            1
    com.intego.iokit.BehavioralKext            1
    com.intego.kext.VirusBarrier.AppBarrierKPI            10.6.8
    com.intego.kext.VirusBarrierKPI            10.6.8
    com.globaldelight.driver.BoomDevice            1.1
    com.huawei.driver.HuaweiDataCardACMData            4.2
    Model: iMac11,2, BootROM IM112.0057.B01, 2 processors, Intel Core i3, 3.2 GHz, 12 GB, SMC 1.64f5
    Graphics: ATI Radeon HD 5670, ATI Radeon HD 5670, PCIe, 512 MB
    Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x802C, 0x31364A53463531323634485A2D3147344431
    Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x802C, 0x31364A53463531323634485A2D3147344431
    Memory Module: BANK 0/DIMM1, 2 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353637334648302D4348392020
    Memory Module: BANK 1/DIMM1, 2 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353637334648302D4348392020
    AirPort: spairport_wireless_card_type_airport_extreme (0x168C, 0x8F), Atheros 9280: 4.0.64.8-P2P
    Bluetooth: Version 4.0.5f11, 2 service, 18 devices, 1 incoming serial ports
    Serial ATA Device: ST31000528AS, 1 TB
    Serial ATA Device: OPTIARC DVD RW AD-5680H
    USB Device: hub_device, 0x0424  (SMSC), 0x2514, 0xfa100000 / 2
    USB Device: USB2.0 Hub, 0x05e3  (Genesys Logic, Inc.), 0x0606, 0xfa140000 / 5
    USB Device: USB2.0 Hub, 0x05e3  (Genesys Logic, Inc.), 0x0606, 0xfa141000 / 9
    USB Device: Apple Optical USB Mouse, apple_vendor_id, 0x0304, 0xfa141100 / 8
    USB Device: CanoScan, 0x04a9  (Canon Inc.), 0x1904, 0xfa141200 / 6
    USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0xfa110000 / 4
    USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8215, 0xfa111000 / 7
    USB Device: Internal Memory Card Reader, apple_vendor_id, 0x8403, 0xfa120000 / 3
    USB Device: hub_device, 0x0424  (SMSC), 0x2514, 0xfd100000 / 2
    USB Device: HUAWEI Mobile, 0x12d1  (Huawei Technologies Co., Ltd.), 0x1001, 0xfd130000 / 5
    USB Device: My Passport 070A, 0x1058  (Western Digital Technologies, Inc.), 0x070a, 0xfd140000 / 6
    USB Device: Built-in iSight, apple_vendor_id, 0x8502, 0xfd110000 / 4
    USB Device: IR Receiver, apple_vendor_id, 0x8242, 0xfd120000 / 3

    Immediate suspects are the additions you added to you rsystem that installed kexts (drivers).  From above,
    com.intego.iokit.VBX6NKE            1
    com.intego.iokit.BehavioralKext            1
    com.intego.kext.VirusBarrier.AppBarrierKPI            10.6.8
    com.intego.kext.VirusBarrierKPI            10.6.8
    com.globaldelight.driver.BoomDevice            1.1
    com.huawei.driver.HuaweiDataCardACMData            4.2
    Two experiments you can try.
    1.  Boot in safe mode and see if you can shut down normally.  All thise additions won't be running in safe mode so this test would indicate it is one of them causing the problem.
    2. Uninstall all the intego VirusBarrier stuff.  That's my first guess and the troublemaker.

  • The "edit in" menu is completely inactive. All plug-ins are visible but in light grey; i.e. not accessible. Any idea how to solve the issue? Fyi: I am using LR 5.7.1 on MacBook with Mawericks.

    The "edit in" menu is completely inactive. All plug-ins are visible but in light grey; i.e. not accessible. Any idea how to solve the issue? Fyi: I am using LR 5.7.1 on MacBook with Mawericks.

    Jim, that sounds like a good hypothesis. Yes, I am using smart previews. I have my originals on an external drive which is connected. Still, LR can not find them. Do you know how to tell LR where to find the originals? I would like LR to identify the source automatically: if external drive is connected LR should show "original and smart preview" not only "smart preview". Thanks for your help.

  • My FaceTime is active but it does not connect. Any one know what is wrong with it or how to solve the problem?

    My FaceTime is active but it does not connect. Any one know what is wrong with it or how to solve the problem?

    Please sign out of FaceTime and sign back in. If there's no change, log out or restart the computer and try again.

  • How can I start anew with Photos and clear the (minimal) stuff it has uploaded

    I've about had it up to here with this new Photos scheme. I reorganised my Aperture libraries on both my iMac and MBA in preparation for this, delayed turning Photos on for a couple of days until I thought everything was ready based upon the limited advice that was out there, and then got stuck in an endless loop of "uploading" and "preparing" every time I opened Photos. There are 19,975 images in my Aperture library on the iMac. I was stuck at Uploading at anywhere between that number and 19,000 with no progress after hours of waiting. I tried all the tricks mentioned here including re booting, restarting the app, repairing/rebuilding the database, killing the "cloudd" process, etc.today Today when I restarted Photos, it now said I had 23,775 images to upload- 4000
    more than I have-and of course it got stuck there, like it has for the last week.
    I copied the previous Aperture library (pre Photos migration)back to my iMac and opened it in Aperture. Thankfully, all the photos I had taken on my iPhone this week during this Photos clusterphuck transition were in the Aperture Stream so I didn't lose any of those. I'm willing to give this whole thing one more shot. So  i need some advice. How can I start anew with Photos and clear the (minimal) stuff it has uploaded (about 6000 of 19,000 images in the last 7 days) ? If I simply delete the Photos.photolibrary file will that do the trick and lt me start a new fresh library using?
    <Re-Titled By Host>

    How can I start anew with Photos and clear the (minimal) stuff it has uploaded (about 6000 of 19,000 images in the last 7 days) ? If I simply delete the Photos.photolibrary file will that do the trick and lt me start a new fresh library using?
    It is hard to say from your post, why the migration did not succeed in your case.
    by "stuck on upload" do you mean, you opened the Aperture library in Photos, and Photos converted it to a Photo Library, and then the upload to iCloud Photo Library did hang?  Or did already the upgrade to the Photo Library fail?
    If you want the Aperture library to upload to iCloud Photo Library, it needs to be on a disk formatted MacOS Extended (Journaled) and the original image files must not be referenced. Referenced originals will not upload.
    Also, the upload may hang, if you do not have enough free iCloud storage, orr if one of the videos or photos in your library is in an unsupported format or corrupted.
    To start over, try to repair and rebuild the Aperture library before opening it in Photos. Try all Aperture Library First Aid options - starting with repairing the permissions.  (Repairing and Rebuilding Your Aperture Library: Aperture 3 User Manual)
    If I simply delete the Photos.photolibrary file will that do the trick and lt me start a new fresh library using?
    You will have to delete the photos that are already in icloud too; otherwise you are risking duplicates.
    Can you launch Photos at all?  If yes, delete all photos in Photos and empty the Recently Deleted album. Wait for the deletion to sync to iCloud. Then delete the Photos.photolibrary.

Maybe you are looking for

  • Profit center at GR IR Clearing Account - MIGO (Account Assignment Q)

    Dear all, We are implementing SAP into a Real estate business client and based on requirements from the Finance we have agreed to have profit centre level balance sheet for each of tower Hence lets take an example There is a project with PC1 (Common

  • New iPhone contacts accidentally synced to Exchange server, how can I get them into my Mac?

    I've been adding a lot of contacts on my iPhone lately and now I wanted them synced to the Address Book on my Mac. This just wouldn't work for me, none of the new contacts would turn up on the Mac, no matter what I tried. After pulling my hair plenty

  • Why does my HP photosmart C6100 loose connectivity and have to be uninstalled and re installed?

    My HP photosmart C6100 printer constantly looses wireless connection and I have to uninstall and reinstall the printer on my laptop. I have been told that this may be because of its age but when it prints it works fine. What can I do to resolve the p

  • Newbe with iWeb question

    Hello all new here and no computer expert by all means so please bare with me. Trying to create a web page for a for a friend What i would like to do is have a bio section for crew members. What would be the best way to do this?????? I would like to

  • Battery wont charge above 82%

    I followed the calibration guide in the manual and let my MBP sleep for a over five hours before plugging the power source back in. I let it charge overnight and when i turned it on the level was only 93%. As i used it, the battery level dropped and