Sockets: setSoTimeout() not working with Scanner

I'm implementing the timeout feature for a server, and I've run into a problem. My server reads from the socket input stream using a Scanner, and I've set the socket timeout using Socket's setSoTimeout() method. This is supposed to throw a SocketTimeoutException, but instead, the Scanner is throwing a NoSuchElementException first (because it's not getting the right input!) and the SocketTimeoutException never gets thrown. If I use InputStream's read(), I don't have this problem (SocketTimeoutException gets thrown properly). Here's how my code is organized:
Accept connection.
Set so timeout.
Spawn thread with socket as its argument.
- Try:
- Decode request from the socket's input stream.
- Catch SocketTimeoutException:
- Send timeout message to client.
Close connection.
Do you know a way around this issue besides replacing Scanner with read()? Or did I do something wrong?
Ben

If it were me I'd catch the
NoSuchElementException first (because it's notand add a comment saying what was going on.
Do you know a way around this issue besides replacingNope
Scanner with read()? Or did I do something wrong?No you haven't done anything wrong. Just catch the exception
>
Ben

Similar Messages

  • Need driver for canon mg 5250 as scanner is not working with version 10.7. Can you please help me to find the driver so scanner works with WIFI?

    need driver for canon mg 5250 as scanner is not working with version 10.7. Lion. Can you please help me to find the driver so scanner works with WIFI?

    Try with the latest Apple driver package for Canon (released 15th Feb):
    http://support.apple.com/kb/DL899
    This solved my problem with the printing.

  • Cannon 8800F not working with OS X yosemite 10.10.1  . I have downloaded the latest drivers and firmware from Canon. I called Canon for support and went through all the checks , but, still my iMac did not see the scanner. Any new ideas?

    cannon 8800F not working with OS X yosemite 10.10.1  . I have downloaded the latest drivers and firmware from Canon. I called Canon for support and went through all the checks , but, still my iMac did not see the scanner. Any new ideas?

    Have you done any of the following?
    http://support.apple.com/kb/PH18614 OS X Yosemite: Reset the printing system
    Repaired permissions & restarted your comp after the installations of the drivers?
    Sometimes, installing the GIMP drivers help with printing issues: http://gimp-print.sourceforge.net/MacOSX.php
    What to do when you can't print
    =============
    not working with OS X yosemite 10.10.1
    Per your profile
    Mac OS X (10.7.3)
    Conflicting info:  Please update/correct your profile so that you can receive the correct troubleshooting suggestions.  This will assist the users in trying to help you.  Thank you.

  • I want to install an old airport express, the ones which are directly plugged into the socket - but it does not work with Maverick or Snow Leopard - can I configure it with a windows pc?

    I want to install an old airport express, the ones which are directly plugged into the socket - but it does not work with Maverick or Snow Leopard - can I configure it with a windows pc?

    The Mac running Snow Leopard should be able to configure virtually any version of the AirPort Express.
    Tell us what steps that you are taking to configure the Express and what happens after each step.

  • My fingerprint scanner will not work with Firefox 4.

    I used to be able to use my fingerprint scanner to log into all of the websites I use like Facebook, YouTube, Yahoo etc... But now since I updated to Firefox 4 it doesn't work anymore. The program that I use is called Digital Persona. How do I fix this issue?

    Another user got this from Digital Persona. <br />
    "Thank you for contacting DigitalPersona. There will be no update releases for DigitalPersona Personal in the future. There will be no updates for Firefox 4 nor Internet Explorer 9. IF they work they work, if they do not work with DPPersonal, then you will have to decide to either keep DPPersonal and forgo Firefox 4 or IE 9, or vice versa. DigitalPersona is leaving the consumer market and is focusing on business applications. In fact, DigitalPersona Personal will not longer be supported after Mid-April of this year. We apologize for any inconvenience this might cause. Sincerely, Tech Team "
    You could try this extension. <br />
    https://addons.mozilla.org/en-US/firefox/addon/fingerfox-se/

  • Hp scanner software Scan 3 does not work with osx yosemite

    The older software called HP Scan 3 does not work with OSX 10.10. Where can I download an update for this software? 

    Hello @ringie,
    Welcome to the HP forums.
    I understand that you would like to scan from your Photosmart premium C410 to your Mac 10.10.
    I would like to help.
    There is currently no updated software.
    Try the following work around.
    Scanning in OS X v10.10 Yosemite without HP Software
    Hope this helps get you scanning.
    Aardvark1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!

  • Applet does not work with a proxy server.URgent

    Hi,
    I have an asp page being hosted from a IIS server.
    The asp page has an applet which gets data from a server side component which is hosted as a service on the server side.For connection to the server I am using URLConnection object and trying to connect over a TCP connection.
    The problem occurs when I use an proxy in the middle.
    I have changed the browser settings to include the proxy.
    The following is the error I recieve:
    Full :http://172.25.11.63:4590/
    <-------------------------------->
    OPening input stream
    in Run ::::
    ERROR: Created data socket but can't open stream on
    it.172.25.11.63:4590//
    172.25.11.63:4590//
    java.io.FileNotFoundException: 172.25.11.63:4590//
         at com/ms/net/wininet/http/HttpInputStream.connect
         at com/ms/net/wininet/http/HttpInputStream.<init>
         at com/ms/net/wininet/http/HttpURLConnection.createInputStream
         at com/ms/net/wininet/WininetURLConnection.getInputStream
         at TalkClientApplet.rendezvous
         at TalkClientApplet.actionPerformed1
         at TalkClientApplet.start
         at com/ms/applet/AppletPanel.securedCall0
         at com/ms/applet/AppletPanel.securedCall
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run
    ...Disconnecting.
    Following is my code.
    url = new URL("http://" + host +":"+i);
    urlconnection = url.openConnection();
    urlconnection.setDoOutput(true);
    urlconnection.setDoInput(true);
    System.out.println("Successfully opened the URL connection at " + "http://" + host + ":" + i );
              System.out.println ("Protocol: " + url.getProtocol());
              System.out.println ("Host :" + url.getHost());     
              System.out.println ("Port :" + url.getPort());
              System.out.println ("File :" + url.getFile() );
              System.out.println ("Full :" + url.toExternalForm());
              System.out.println ("<-------------------------------->");
    os = new BufferedWriter(new OutputStreamWriter(urlconnection.getOutputStream()));
    System.out.println("OPening input stream ");
    // is = new DataInputStream(urlconnection.getInputStream());
         System.out.println(urlconnection.getInputStream());
    is = new DataInputStream(urlconnection.getInputStream());
    The exact place where I get the error is whn i call URLConnection.openInputStream().
    Usually this error comes with a malformed URL.But the same code words without a proxy.Also I am not making any changes to my code in both scenarios that is with or without proxy.
    Please help.This is urgent and a showstopper

    Thanks for your nice solution, but unfortunatelly it does not work with lines longer than 100 chars with Netscape. It works fine with IE and appletviewer too.
    Example:
    I use this code:
    try {
                URL url = new URL(protocol,hostName,portNumber,URLstring);
                InputStream in = url.openStream();
                BufferedInputStream bis = new BufferedInputStream(in);
                StringBuffer input = new StringBuffer(60);
                int c;
                while ((c = bis.read()) != -1){
                    System.out.print((char)c);
                    input.append((char)c);
                bis.close();
                dataFromServer = input.toString();
            catch(Exception ex) {
                ex.printStackTrace();
            }I use input file test.html with exactly 100 chars ('a')
    Netscape Java Console:
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadataFromServer : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaI use input file test.html with exactly 101 chars ('a')
    Netscape Java Console:
    ?JL?yyxk?cedataFromServer : ?

  • Why does Java Application not working with Macromedia Flash 5 or MX?

    Why does Java Application not working with Macromedia Flash 5 or MX?

    Who says they don't?
    Although I don't know much about those I'd think they should be able to talk to Java Aps using Sockets or request Servlets ...
    Spieler

  • Canon Pixma MP-540 (and other) does not work with Cups 1.4

    Since Cups 1.4 my printer does not work
    its 100% about Cups 1.4 beceause after an downgrade to 1.3 it worked perfect. After upgrade to 1.4 again nothing worked.
    So my question, could there be maybe a package called cups-legacy. I heard about other Canon printers + non canon printers which not work with Cups 1.4 in case of binary distributed drivers

    I had a similar problem with my MP780 and solved it by adding a custom udev rule. See http://wiki.archlinux.org/index.php/Cup … ermissions. This is my udev rule:
    SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="04a9", ATTR{idProduct}=="1707", GROUP:="lp", MODE:="0660"
    and lsusb output:
    Bus 001 Device 003: ID 04a9:1707 Canon, Inc. PIXMA MP780 Scanner
    . Hopefully this will be fixed by hal/devicekit/udev upstream but it all seems a bit of a jumble atm, to me anyway.

  • McAfee is not working with OS x 10.10.1 - do I need it

    OS X Yosemite Version 10.10.1
    I have an iMac (27 inch, Mid 2011)
    Processor 2.7 GHz Intel Core i5
    Memory 4GB 1333 MHz DDR3
    Start up Disk Macintosh HD
    Graphics AMD Radeon HD 6770M 512MB
    This is my 1st posting for help, so please excuse me if I am not following the correct procedures.  Yesterday I installed the latest update for Yosemite and at the end of the process I was advised that the McAfee security software would not work with the update 10.10.1.  My question is do I need McAfee, or does my iMac have it's own Firewall and other security systems already in place.  I would welcome any recommendations on alternative security packages, that members use, if they are working with this latest update.

    Hi All... Long time Apple user and have enjoyed many many years without a thought about malware, virus' and trojans. However as this dialog progresses I would like to share an unfortunate reality... Life was fine and then one day my MacBook Pro started to labor when opening apps/managing multiple documents/etc.. the spinning wheel - and when I pulled up the option to Force Quit - each time it would show me that one or another of my apps was 'unresponsive'. (when I did not force quit the app - it did finally become responsive after a number of minutes) Next... noticed two things; at the same time that a mac app was unresponsive - the fan in my macbook was kicked into overdrive... and the casing above the keyboards had become super hot. Researched the issue that pointed me to the possibility of malware... Chose then what was best option McAfee to scan my computer.... and yes you guessed it - two cases of malware and a trojan. McAfee put them in 'quarantine' and I restarted my laptop... Like magic - no unresponsive apps - the fans were calm and the case was no longer excessively hot. This was great for about a month and then it happened again... ran the scan (with McAfee and Sophos) and found a new case of malware that was found in my email database and dated as received that day - once the virus was quarantined - my macbook was happy again. Now I run realtime virus scanner - seems like about 3-5 weeks and something will show up and - 99.9% time imbedded within an email - but computer is running as it should fast, cool and quiet.

  • Now a few of programs does not work with mountian lion. what to do?

    now a few of programs does not work with mountian lion. what to do?

    espons printer/scanner, toast titanum 5.2.1, intuos 4 wacom, appleworks, already updated ms office & order the upgrade for reunion which I hope it will work. 
    thank you mr michael allbritton for your help!

  • Canoscan 9950F still not working with 11/26 fix from Canon

    Just reported this to Canon. Image Capture and VueScan both work. I can get the scanner to work on a MBP but not on the G4 iMac .... except on a fresh install and only one user account. I you create a 2nd user (not even migrate data, just create a 2nd user), the Canon Toolbox appears to lose its pathing to the scanner driver. Bizarre.
    I've deleted the TWAIN driver manually and using the Canon utility (from the web site). I've installed, reinstalled, uninstalled every combination of Toolbox and TWAIN driver imaginable. So it's back with Canon .... close but

    This may not help you, but here is what I found.
    I have a Flatscreen G4 iMac 1.2G. I have had no end of trouble with the USB ports since moving to Leopard.
    The first problem I had was that TimeMachine would not work with my Seagate 500G FreeAgent disk. Sometimes it would not mount, file corruption etc. Thought I had a stuffed USB adaptor.
    Somewhere amongst this greif I notice that my Canon LIDE50 scanner would not work any more.
    There are numerous threads around the place on this issue. This scanner is claimed to not work with Leopard. Anyway, at this point I disconnected the scanner and also upgraded to 10.5.1. TimeMachine now works fine.
    Since then, the scanner has been on our MacBook Pro using BootCamp. I did try Vuescan, it does work, but I'd rather use the Canon tools for what I'm doing.
    Tonight I did a bit of poking around to make sure all the files for the scanner installed in the right places. During this process I notice the USB disk had gone missing again. To cut a long story short, the USB disk and the Canon LIDE50 scanner are mutually exclusive. Plug only the scanner in, it works. Plug only the disk in, it works. Plug them both in, neither work! At this point I'm shutting down and restarting to change them over, but at least I have a work around.

  • I have recently upgraded my iMac Intel G5 iSight to OS 10.6.8 and now the internal mic does not work with skype or facebook. I can here static when playing back clips. Do I need to update firmware or reload old sys parts

    I have recently upgraded my iMac Intel G5 iSight (iMac5,1) to OS 10.6.8 and now the internal mic does not work with skype or facebook. I can here static when playing back clips. Do I need to update firmware or reload old system parts. I have zapped PRAM. The blue indicator in system audio panel will appear for a second as I slide the bar for internal mic but then it disappears. Is there a fix?

    The sound seems very faint but can here static on playback.

  • My operating system windows XP not working with photoshop cloud, why not?

    I need to add 2 more licences for photoshop cloud and I'm being told my operating system windows XP does not work with Photoshop cloud. We already have 2 pcs using it in our office so why not?
    Please help
    Roy

    Do you have the latest version of iTunes?  If not, get it at:
    http://www.apple.com/itunes

  • Adobe creative cloud eea 1.5 is not working with our asus Eee box , celeron j1900 2.00 ghz, 4gb of ram, 64bit. can settings be changed in adobe?

    adobe creative cloud eea 1.5 is not working with our asus Eee box , celeron j1900 2.00 ghz, 4gb of ram, 64bit. can settings be changed in adobe?

    A chat session where an agent may remotely look inside your computer may help
    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

Maybe you are looking for

  • Open second vi and close the first vi

    i want to open the second.vi to be open from one.vi and,, and at the same time i want to close one.vi,,, i find may answers in labview about this but any of them could not setisfy my requirment,,, manisha

  • Computer won't start up after 10.5.1 update

    My leopard updates were a little rocky, but I got everything working eventually. However, after installing the 10.5.1 update yesterday, my computer no longer starts up properly. It hangs up for a VERY long time on the initial screen with the gray app

  • Changing url's from Podomatic to My Website

    Hi there, I'm confused. I have read the instructions to this topic but don't understand how to implement the change. I understand the change tag is <new-itunes-feed-url> which I need to put before and after the feed url, but which feed url the old on

  • EJB missing expression builder

    I'm getting an exception: Exception Description: The query has not been defined correctly, the expression builder is missing. For sub and parallel queries ensure the queries builder is always on the left. Query: ReportQuery(profil.Person) this is my

  • Syncing w/iTunes: Info Tab

    I seem to recall that when MobileMe is enabled as your syncing method, the Info tab in iTunes would say something to the effect of "your information is being synced over the air with MobileMe." Now, since iTunes 9.2 and iOS4, this doesn't appear anym