Socket I/P stream's read fails to throw IOException when connection is lost

Hi,
Socket.getInputStream().readShort() blocks till it reads from the server. It throws an IOException if the connection is lost before calling the method. But it is not throwing an IOException if the connection is lost after blocking.
That is....
// If the connection is lost before calling, it is throwing an IOException.
short s = mySocket.getInputStream().readShort();
// But, while it is blocked and if I shutdown the server, it's never throwing
// an IOException and it stays blocked.How should I get around this problem?
Thank you!

It's true; a timeout is really the best way.
One approach I thought about using, where I was in control of the protocol, was to periodically send a "nop" type operation to the socket; a message that doesn't do anything. Obviously not all applications have this liberty, either because you aren't in control of the protocol, or because you want to keep your application single threaded. It's also kind of hackish, and not as good as the timeout mechanism in most respects.
You also have to be a little careful about what you define as a "connection failure". If, for example, you set up a TCP/IP socket without a timeout, and then physically disconnect the ethernet cable, the connection will in fact stay up. If you come back an hour later and plug in the cable again, the connection will still be there and will pass traffic again.

Similar Messages

  • After itunes update my ipod touch is not syncing correctly first I got error message..ipod failed to complete sync because connection was lost..now it wont sync new music

    After recent itunes update my ipod touch 4 is not syncing properly...I got error message twice "ipod failed to sync properly because connection was lost, please try again"... it continued acting weird, now when i click on "sync now" it says preparing to sync, it goes through steps quickly says sync finished but it doesnt update.. can anyone help?

    There's a good guide here on how to roll back to 10.7 https://discussions.apple.com/thread/4559563?tstart=0

  • Syn read file adapter throwing exception when file is not present directory

    Hi Team,
    Requirment is to check for a file is present in a soa directory .If present delete the existing and write a new one.
    Syn read file adapter is throwing errors when file is not present in the directory soa local.
    Any paramter we can add to skip this exception.
    any help is appreciated.
    Thanks all
    Swetha H.

    Hi:
    An alternative is that , before u try to read it, u make a list directory, and search for ur file, if it is not in the list, then u don't read; otherwise, u do.
    The list operation is part of the file adapter.
    hope this helps
    best

  • Can't stream music from iPhone to airport express when connected to internet

    I have an issue with my airport express. When the unit is used solely for streaming music from my IPhone to connected stereo speakers without an Ethernet cable attached it works fine.  When I attach an Ethernet cable to the airport express and connect to the Internet on my iPhone, the airport express will no longer stream music from the iPhone. This is a recent problem, previously I was able to access the Internet on my iPhone from the airport express, whilst simultaneously streaming music from the iPhone back to the airport express.

    Do you mean Lan cable? Can this be done wirelessly from itunes to airport express without the internet connections?  I can't connect to an airport express that's not connected to the internet.

  • Failing to load webpages when connected at work (works fine else were)

    I have a PowerBook G4 that I moved between work and other locations. I have never had any issues before, but now I am getting a very strange issue in Safari (1.3.2). If I enter the domain name of the site (say www.apple.com) it fails to ever connect, but if I put in just an IP address it is fine. This caused me to think "Hurm...DNS lookups are failing for some reason". But this seems to not be the case. I can open up terminal type "telnet www.apple.com 80" and then "GET index.html" and it works just fine. So DNS looks ups are atleast working Terminal. Also, this only occurs when I am at work. We have no other machines on the network that experience this problem. All other machines there are just fine.
    Any ideas?
    PowerBook G4   Mac OS X (10.3.9)  

    I will say that Linksys Routers are notorious for being subpar. My suggestions would be to disconnect the router and cable modem and turn off the computer (and everything).
    Then, wait fifteen minutes.
    Then, turn on the cable modem. Let it go through all its blinky phases, then turn on the router. Wait at least three minutes for ole' cranky to wake up. Now turn on your Mac.
    This is what you have to do when a router forms a bad DHCP client lease.
    An alternate first step would be to manually enter your own IP address that's the same everything except make up a 200 range number and throw it in for Z on the equation before .*..Z.
    E.G.: if your DHCP address is 192.168.3.43, make up your own ending and manually enter it. 192.168.43.200. Set the router as x.x.x.1 (e.g. 192.168.43.1) and SubNet as 255.255.255.0

  • IPod Restore failed, now Kernel Panic when connect to Mac

    My iPod is a little older and has had trouble updating though the iPod Updaters so in order to get the latest updater on my iPod I've had to just restor the iPod using that specific updater. iPod Updater froze during my last restore and now I have incomplete software on my iPod and connecting it to my Mac results in immediate kernel panic. How can I get my iPod back to a usable state?
    Thanks.

    Just got back from trying this idea and IT WORKS. For people that might have this problem, I booted from the CD/DVD and lauched Disk Utility and did a Repair Disk. I did it twice actually for good measure. Afterwards I booted back to the System Folder on the HD and I performed a restore of my iPod using the iPod Updater 2005-06-26.app updater. I've read that my whatever generation iPod works best with that one (I have the click wheel with the 4 buttons above it).
    Thanks for all your help.

  • Webtogo fails to go offline when connection lost

    HI folks,
    I am using the latest release of webtogo with 9iLite. I am using a gprs modem to establish a tcp/ip based VPN connection to our office with a private apn. This is very similar to a normal internet connection via an isp. Going offline and online from the buttons in the web interface works fine. The problem is when there is an unexpected problem with the GPRS connection such as the GPRS service going down or the modem being turned accidentally off, the webtogo local app. does not work. It hangs after the login info has been entered. It expects to connect to the mobile server to go offline, which it can't. Are there any settings to correct this situation.

    There is no server communication anymore after the client is offline mode. Everything is local, even the authentication. To prove this, disconnect the network cable while offline and see it you can login and launch the application.
    The network drive might have a problem after the GPRS model was shut down. Shutdown the client, disconnect the GPRS modem and startup the client again. If you are able to login and launch the application then you know the problem is the GPRS network driver,

  • Socket read fails but write is successful. Why?

    Hi once more!
    I have a Java application, reading and writing from/to a client socket:
    InputStream is = socket.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    i = br.read();
    ...If i is equal to -1, it means there's no connection or that somehow the connection is unavailable right? So, how come is it possible to write to the socket's output stream with success after that read( ) returning -1? Shouldn't it also fail?
    I'm trying a "persistent" TCP connection, so I use that condition (read () == -1) to determine when the connection is down (read() is only blocking a certain amount of time).
    Thanks!

    I suggest you to have a process constantly
    sending a byte just to check that you still have
    the ability to send a packetNow you've got it.That's what I'm doing, yet I feel in my case it's not enough.
    I communicate with the server asynchronously. I send packets.. somewhen the server sends packets to my client.
    This way, I have to be continuously reading from the socket's Input Stream, in order to check for incoming packets (which may arrive at any time)... Thus, I have to be sure I can read from the socket..
    As the connection may timeout (if neither my client nor the server write anything to the socket) I send a dummy packet once per minute.
    However:
    1) This is too long to check connection status (only 1 time each minute)
    2) It doesn't tell me I can read ok from the socket - check the case where I could write but read ( ) returned -1. This is abnormal behaviour in my case.. do you think if the server was sending some packets, my read ( ) would be able to capture them (even after returning -1 for quite a while)? It seemed to me I was able to send, yet unable to receive.. or my packets weren't actually reaching the server even though they seemed to be.
    What write does is cause packets to be sent which
    require acknowledgement, and if the ACKs don't
    arrive, eventually a subsequent write() will fail. A
    read doesn't engage in any wire protocol at all,
    which is why it can't be used to detect a connection
    failure other than via a read timeout, or as a result
    of prior writes.Why does write ( ) doesn't fail when I unplug the cable? Either way this situation isn't quite important, as long as my packets start actually reaching the server after the cable is plugged back in. Curious, however, how write ( ) doesn't fail..

  • Why should Adobe Reader fail to print because of settings in the Edit/Preferences?

    AdobeReaderDocumentCouldNotPrint.txt
    Glyn Price Tue 17 March 2015
    Why should Adobe Reader fail to print because of settings
    in the Edit/Preference?
    Adobe Reader XI Version 11.0.10
    MS Window 7
    File > Print > Print
    I got the error message:
    The document could not be printed
    I googled this error message and used the following
    solution that worked i.e. it then printed successfully.
    Edit >  Preferences
    Category: Security(Enhancement)   'Enable Protected  Mode at Startup'
    It was checked, changed it to unchecked.
    Category: Documents    'View documents in PDF/Mode'
    It was set to 'Only for PDF/A'
    Set it to 'Never'
    Exited Adobe Reader and restart it. Then it printed.
    I had a look on another computer system (Adobe Reader XI Version 11.0.10
    and MS Window 7) and on this different computer I could print
    without doing the above two changes.
    I'm a bit puzzled. Why preferences on one system were not
    needed on a different system?

    Here is an elaborate method of troubleshooting this problem. There may be a simpler method if anybody wants to suggest one.
    There is a general technique that is helpful in this situation. I can't give you complete instructions here, and I haven't tested this with regard to bluetooth devices, but here's the gist of it.
    Create a second log-on account for your music projects. Configure it so that when you log in to the new music account, the drivers needed for the Bluetooth devices don't load. You do this in System Preferences: Accounts.
    When it's time to do music, log out of your usual account and onto the new one.
    When you install drivers for any peripheral, you have the option of installing them "for all users" or only for the user account that is active during the installation.
    This governs whether the drivers go in root/library or root/Users/your name/library.
    If drivers are in root/library, they will load whenever the Mac is booted up and will run for all users.
    But if drivers are loaded in root/Users/your name/library, they will only load if you log in as "your name". If you have a second account called root/Users/music account/, and you log in under that, the drivers in "your name" will not load. Get it?
    To get this working right you need to be knowledgeable about moving or deleting files in the /library/ directory and subdirectories, and you need to be careful because you can unwittingly cause some damage if you are not careful.
    There is also the root/System/library directory, and in general you should never mess around with anything in there or you might hose your system.
    In summary, I would start by using the installer programs for your BlueTooth devices and DE-installing all drivers. Reboot. Log back in as your usual user account. Then RE-install each driver and see if the installer program gives you the OPTION to installl for all users or just for this user. Choose the latter. Then log on to your new Music account and see if the problems go away.

  • Help! I have recently updated LR5 and before doing so I was able to email files to clients! (Very Convenient) Now my problem is I have not been able to get pass this error message reading "failed to send" which gives no further detail about what to do to

    Help! I have recently updated LR5 and before doing so I was able to email files to clients! (Very Convenient) Now my problem is I have not been able to get pass this error message reading "failed to send" which gives no further detail about what to do to rectify the situation. Someone please guide me through this! Thanks in advance!

    Did this ever get resolved, as I am having the same issue.  Trying to learn LR5 AFTER a decade using Aperture.   I was able to set up a validated account but when I try to send an e-mail or photo I get the simple " Failed to Send " message.   Using latest version of Mac OS X.

  • File Adapter: Fixed length file read fails when all data not present

    Hi
    We have a BPEL process that reads fixed length data files. It works fine when all the data elements are available in the file but fails with 'rejected:10002' when even a single data is missing.
    How to handle this situation in BPEL file adapter?
    Are we doing something wrong or is this a normal functionality.
    If yes, then is there any work around for this as this is a very usual business condition which may occur, where all data elements are not mandetory.
    fixedLength
    ==========
    2,3,3,2
    Data - Successful
    ============
    1234567890
    2345678901
    3456789012
    Data - Failed
    ===========
    1234567890
    2345678901
    345678901
    Thanks in advance
    Buddhadev

    Hi Naveen,
          Do check the following things,
    >>Note : I have been asked to give the Transport Protocol as "NFS" (Whether this is the problem???) I have summarized the complete details below. Please help me
           1.If your file resides on your local network/local computer give NFS(Network file system). if your file resides on a FTP location give FTP and also give the FTP log on parameters.
    Additional Parameters
    File_MT.fieldFixedLengths 10,10,5
    File_MT.fieldNames VendorNumber,VendorName,City
    File_MT.fieldSeparator
    File_MT..processFieldNames fromConfiguration 
           2.If this structure does not match with the input file structure the file adapter wont pick up the file. So check for the help document provided by SAP in the following path.
    help.sap.com  --> Documentation  --> SAPNetWeaver --> SAPNetWeaver '04 --> English --> process integration --> SAP Exchange Infrastructure --> connectivity --> Adapters --> File Adapter
           Your file contains three records
    V123456789 A123456789 Bosto
    V234567890 B123456789 Atlan
    V334587900 C123456789 Austi
    You have mentioned the fieldSeperator as space but there is no File_MT.endSeparator '/n'  which differentiates between each and every row (record).
            Parameters for Record set Structures mentioned in the sender adapter configuration does not match with the actual file structure .
            Try giving exact structures in the configuration of sender file adapter.
    regards,
    Aravindh.

  • SOAP: call failed: java.io.IOException: unable to create a socket ??

    Hi
    I am getting the following error in PI for one of my sync interfaces.
    SOAP: call failed: java.io.IOException: unable to create a socket
    The interface works most of the time, but i get this error couple of times a day.
    Regards,
    XIer

    Hav you able to resolve this issue? Please let me know what was cause of this "unable to create a socket"
    Thanks,
    Sagar

  • Error SOAP: call failed: java.io.IOException: Read timed out; HTTP 200 OK

    Hi PI gurus,
      Need some suggestions on one issue below -
      Scenario - proxy (SAP) to SOAP (Web based system)
      In the RWB Communication Channel Monitirong we are receiving the below error
      " Error SOAP: call failed: java.io.IOException: Read timed out; HTTP 200 OK"
    the request from XI system is going to target system and printing the lables (as per the functionality) with no issues but the comminication channel is giving the above error and this is causing the repeated sending the same request to target sytem and the data is printing repeateadly. This issues is occuring in Quality environment.
    Strangley the same Interface with the same connectivity details is working fine in Development environment. But not working in Quality environment. Checked the firewalls settings on both in XI and Target system side and confirmed that everything is fine.
    Below are the Logs both from Quality and developement are as follows
    Quality ( Failure Case) 
    17.03.2011 07:19:59 Success SOAP: request message entering the adapter with user J2EE_GUEST
    17.03.2011 07:25:03 Error SOAP: call failed: java.io.IOException: Read timed out; HTTP 200 OK
    Development     (Success ful)
    17.03.2011 07:27:55 Success SOAP: request message entering the adapter with user J2EE_GUEST
    17.03.2011 07:27:58 Success SOAP: completed the processing
    When we checked with basis team on user id J2EE_GUEST,  they confirmed that they are same in Development and Quality.
    I repeat,, that the same target url and everthing is same in XI Configuration
    Thanks in Advance. Points would be rewared for the best solution.
    Thanks,
    Jitender

    HI Jitender,
          If your scenariois working in DEV and if it is not working in QAS.Could you please check if both the systems are at same patch levels..
    Please refer below notes :1551161,817894,952402.
    Cheers!!!
    Naveen.

  • DiB0070 I2C read failed errors on Sony playTV dual tuner.

    Hi Guys,
    As far as I can tell Googl'ing around this error has been aroung since 2008 in the dvb-usb-dib0700 driver.
    I get the following in the log:
    [ 271.882232] DiB0070 I2C write failed
    [ 612.809450] DiB0070 I2C read failed
    [ 792.722569] DiB0070 I2C write failed
    [ 969.609201] perf samples too long (2515 > 2500), lowering kernel.perf_event_max_sample_rate to 50000
    [ 2011.890312] DiB0070 I2C write failed
    When there is enough of them in the log, the tuner stops working. It has crashed at the point as well, see:
    [39237.817501] DiB0070 I2C read failed
    [39648.715000] DiB0070 I2C write failed
    [40324.499602] divide error: 0000 [#1] SMP
    [40324.499637] Modules linked in: udf ctr ccm bnep rfcomm bluetooth parport_pc ppdev arc4 snd_hda_codec_hdmi snd_hda_codec_realtek rt2800usb rt2800lib crc_ccitt rt2x00usb rt2x00lib dvb_usb_dib0700 dib7000p dib0090 dib7000m dib0070 mac80211 snd_hda_intel dvb_usb snd_hda_codec dib8000 rc_imon_mce dvb_core cfg80211 snd_hwdep dib3000mc snd_pcm dibx000_common snd_seq_midi snd_rawmidi imon snd_seq_midi_event rc_core snd_seq snd_timer snd_seq_device hid_appleir joydev snd soundcore snd_page_alloc serio_raw asus_atk0110 lpc_ich mac_hid lp parport hid_generic usbhid hid pata_acpi radeon ttm drm_kms_helper firewire_ohci drm r8169 firewire_core crc_itu_t mii pata_marvell i2c_algo_bit
    [40324.500094] CPU: 1 PID: 2605 Comm: kdvb-ad-0-fe-0 Not tainted 3.13.0-35-generic #62~precise1-Ubuntu
    [40324.500144] Hardware name: System manufacturer P5Q-EM/P5Q-EM, BIOS 2203 07/08/2009
    [40324.500189] task: ffff880079efb000 ti: ffff88007995a000 task.ti: ffff88007995a000
    [40324.500231] RIP: 0010:[<ffffffffa0480b6a>] [<ffffffffa0480b6a>] dib7000p_set_dds+0x3a/0x140 [dib7000p]
    [40324.500292] RSP: 0018:ffff88007995b928 EFLAGS: 00010246
    [40324.500323] RAX: 0000000004000000 RBX: ffff880034fb6000 RCX: 0000000010624dd3
    [40324.500363] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff880034fb79a0
    [40324.500403] RBP: ffff88007995b968 R08: ffff88007995a000 R09: ffffea0001e16c00
    [40324.500444] R10: ffffffff8156b26a R11: 0000000000000000 R12: 0000000000000000
    [40324.500484] R13: 0000000000000000 R14: ffff880034fb6000 R15: 0000000004000000
    [40324.500524] FS: 0000000000000000(0000) GS:ffff88007fc80000(0000) knlGS:0000000000000000
    [40324.500570] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    [40324.500603] CR2: 00007f1fe9d293d0 CR3: 0000000077c69000 CR4: 00000000000007e0
    [40324.500643] Stack:
    [40324.500656] 0000000000000040 0000000000000384 ffff88007995b968 ffff880034fb6000
    [40324.500704] ffff880034fb6000 ffff880034fb6000 0000000000000002 0000000022739480
    [40324.500750] ffff88007995b9b8 ffffffffa0480e9e ffff880078d3a8f0 0000000000000441
    [40324.500797] Call Trace:
    [40324.500818] [<ffffffffa0480e9e>] dib7000p_agc_startup+0x22e/0x480 [dib7000p]
    [40324.500862] [<ffffffffa0483382>] dib7000p_set_frontend+0x72/0x1f0 [dib7000p]
    [40324.500911] [<ffffffffa040e78e>] dvb_frontend_swzigzag_autotune+0x13e/0x350 [dvb_core]
    [40324.500961] [<ffffffff8156b26a>] ? usb_control_msg+0xea/0x110
    [40324.501002] [<ffffffffa040f8aa>] dvb_frontend_swzigzag+0x29a/0x3c0 [dvb_core]
    [40324.501048] [<ffffffff810135da>] ? __switch_to+0x12a/0x4d0
    [40324.501083] [<ffffffff810a5d2d>] ? set_next_entity+0xad/0xd0
    [40324.501118] [<ffffffff810789ff>] ? try_to_del_timer_sync+0x4f/0x70
    [40324.501155] [<ffffffff81078a72>] ? del_timer_sync+0x52/0x60
    [40324.501191] [<ffffffff8175d345>] ? schedule_timeout+0x135/0x250
    [40324.501228] [<ffffffff81078620>] ? call_timer_fn+0x160/0x160
    [40324.501268] [<ffffffffa0412a64>] dvb_frontend_thread+0x454/0x7c0 [dvb_core]
    [40324.501311] [<ffffffff810affd0>] ? __wake_up_sync+0x20/0x20
    [40324.501351] [<ffffffffa0412610>] ? dvb_frontend_ioctl+0x160/0x160 [dvb_core]
    [40324.501393] [<ffffffff8108fb59>] kthread+0xc9/0xe0
    [40324.501423] [<ffffffff8108fa90>] ? flush_kthread_worker+0xb0/0xb0
    [40324.501460] [<ffffffff8176ab7c>] ret_from_fork+0x7c/0xb0
    [40324.501493] [<ffffffff8108fa90>] ? flush_kthread_worker+0xb0/0xb0
    [40324.501528] Code: 7d f8 41 bf 00 00 00 04 48 89 5d d8 4c 89 65 e0 4c 89 6d e8 41 89 f5 4c 89 75 f0 49 89 fe e8 6e ff ff ff 31 d2 41 89 c4 44 89 f8 <41> f7 f4 8b 0d ad 67 00 00 41 89 c7 44 89 e8 c1 f8 1f 89 c3 44
    [40324.501731] RIP [<ffffffffa0480b6a>] dib7000p_set_dds+0x3a/0x140 [dib7000p]
    [40324.501776] RSP <ffff88007995b928>
    [40324.516014] ---[ end trace 6a9fad8fe9eb61e2 ]---
    Anyone know how I can fix this? I have tried upgrading to the latest kernel 2.13 and have compiled and installed the latest v4l drivers.
    I have also tried vairous module parameters for the relevent modules. i.e
    options dvb_usb disable_rc_polling=1
    options dvb_usb_dib0700 force_lna_activation=1
    options dvb_core dvb_powerdown_on_sleep=0
    Nada!
    Any help much appreciated.
    Last edited by bmentink (2014-09-20 03:38:44)

    The first thing to do is use smartctl to test the drive. Start with the short test ( smartctl -t short /dev/sdX ), and if it passes run the long test ( ... -t long ... ).

  • I have a book in my library but when I went open to continue to read "failed to load book because the requests resource is missing"?  Where is it.

    I have a book in my library but when I went open to continue to read "failed to load book because the requests resource is missing"?  Where is it.

    Swipe to the right from your home screen and do a search. See if the app shows up. If it does - tap on it just to make sure that it works.
    You can swipe from screen to screen to look for it in order to find the icon. It may have ended up on a far off screen or in a folder somewhere on the iPad.

Maybe you are looking for

  • Delivery doc is deleted in R/3, but not in BW

    I've a situation that a delivery was deleted in Logistics dep in R/3, nevertheless it is still in my BW. It was deleted like 2 months ago from R/3 and i use a standard 2LIS extraction. And the weird thing is In 2LIS_12_VCITM it was deleted because is

  • Company code in Spain

    Hi I am going to create a Spanish company code on SAP and I have an SAP document from 2001 that advises on Spain which helps with the legal requirements,  however I wondered if anyone could tell me if there is a later version of this PDF or any other

  • My Book won't mount to desktop

    Had a power outage and My Book won't mount to the desktop. Running 10.9.5. Disk utility sees it. Won't mount it and says it needs to be repaired, but won't repair it. My book still is doing it's thing, light blinks and shuts down when Mac does. How d

  • Scheduling of Parallel Sequence in Routing & Production Order

    Hello Friends, I have gone through sap library & many other threads related to maintaining & scheduling of parallel sequence in Routing as well as Production Order. For the example, I have 3 operations : 0010,0020 & 0030. I want to maintain 0020 & 00

  • Dotted line is not exported correctly form Indesign to pdf

    My dotted lines do not export as exactly round dots but with kind of "erroded" outlines. Has anyone encountered the same problem yet? How can I solve it? I used the "export for high res print preset". Thanx!