As far as the platform allows/enables PJC read throws an exception if a device is unplugged. Which platform you are using? For Linux and Mac OS X, the inputstream.read() is very thin layer over the POSIX read() and if the OS does not return from a read when the device becomes dysfunctional there is little that can be done. IIRC in that respect OS X did not behave as it should. br Kusti From: ant elder <ant.elder@xxxxxxxxx<mailto:ant.elder@xxxxxxxxx>> Reply-To: "purejavacomm@xxxxxxxxxxxxx<mailto:purejavacomm@xxxxxxxxxxxxx>" <purejavacomm@xxxxxxxxxxxxx<mailto:purejavacomm@xxxxxxxxxxxxx>> Date: Thu, 21 Nov 2013 12:32:06 +0200 To: "purejavacomm@xxxxxxxxxxxxx<mailto:purejavacomm@xxxxxxxxxxxxx>" <purejavacomm@xxxxxxxxxxxxx<mailto:purejavacomm@xxxxxxxxxxxxx>> Subject: [purejavacomm] Detect usb cable unplugged? Is there any way to have an application notified by PureJavaComm when a usb serial port is unplugged? Presently unplugging the cable without first closing the PureJavaComm SerialPort can cause a hang if a read is done on the still open port. It would be nice if the application could be notified when the cable is unplugged and so close the SerialPort, or at least if a read on a SerialPort thats been unplugged would throw an exception. ...ant ________________________________ This e-mail may contain confidential or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. We will not be liable for direct, indirect, special or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed on or as of transmission of this e-mail in general.