Serversocket.close() not causing accept() to throw IOException

My problem is quiet simple. The follow code does not display the string "accept() failed or interrupted..." on the console. Which I believe is part of the Java specification. The code DOES work on a RedHat Linux machine running Java 1.4.2 and 1.5.0, and it works on a machine with Windows XP and 1.4.2, but it does not work on my SuSE Linux machine with 1.4.2, 1.5.0, or any other 1.4.x jvm I've tried.
What could be wrong?
import java.net.*;
import java.io.*;
class Example5 extends Thread {
  volatile boolean stop = false;
  volatile ServerSocket socket;
  public static void main( String args[] ) throws Exception {
    Example5 thread = new Example5();
   System.out.println( "Starting thread..." );
   thread.start();
   Thread.sleep( 3000 );
   System.out.println( "Asking thread to stop..." );
   thread.stop = true;
   thread.socket.close();
   Thread.sleep( 3000 );
   System.out.println( "Stopping application..." );
   System.exit( 0 );
  public void run() {
    try {
      socket = new ServerSocket(7856);
    } catch ( IOException e ) {
     System.out.println( "Could not create the socket..." );
      return;
    while ( !stop ) {
     System.out.println( "Waiting for connection..." );
      try {
       Socket sock = socket.accept();
      } catch ( IOException e ) {
      System.out.println( "accept() failed or interrupted..." );
   System.out.println( "Thread exiting under request..." );
}

I actually already have a work around, we have set the SoTimeout for our ServerSockets. I also have this problem on regular Socket's as well, and have set their SoTimeout as well.
On a somewhat related note, I'm getting a Hotspot Virtual Machine exception when I try and send some data over one of these connections. Since none of my coworkers have this problem, I assume it has something to do with my computer.
# An unexpected error has been detected by HotSpot Virtual Machine:
# SIGSEGV (0xb) at pc=0x403afd0f, pid=23569, tid=1075155072
# Java VM: Java HotSpot(TM) Client VM (1.5.0_01-b08 mixed mode, sharing)
# Problematic frame:
# V [libjvm.so+0x255d0f]
--------------- T H R E A D ---------------
Current thread (0x0807fed0): JavaThread "main" [_thread_in_native, id=23569]
siginfo:si_signo=11, si_errno=0, si_code=0, si_addr=0x00000000
Registers:
EAX=0x4047f0a4, EBX=0x404905a8, ECX=0x0807fed0, EDX=0x0807fed0
ESP=0xbfff9f44, EBP=0xbfffa09c, ESI=0x00000000, EDI=0x0807fed0
EIP=0x403afd0f, CR2=0x0000004c, EFLAGS=0x00010202
Top of Stack: (sp=0xbfff9f44)
0xbfff9f44: bfff9fac 47a6f6b8 00000000 00000000
0xbfff9f54: 00000002 00000000 00000000 695f6d61
0xbfff9f64: 0074696e bfff9f88 08080860 bfff9fac
0xbfff9f74: 00000000 00000000 0807fed0 0807fed0
0xbfff9f84: 08085c20 bfff9fa8 063afc44 bfffa01c
0xbfff9f94: 47a6f568 47a6fbd8 0809cb08 bfff9fa8
0xbfff9fa4: 40033ce0 bfff9fc8 47da1df4 47a6f568
0xbfff9fb4: 40012f4c 47a6fbd8 40013ca6 40013ca6
Instructions: (pc=0x403afd0f)
0x403afcff: d2 0f 84 90 00 00 00 8b 75 10 8b 83 cc 09 00 00
0x403afd0f: 8b 4e 4c 8b 38 89 8d d8 fe ff ff 85 ff 0f 85 4e
Stack: [0xbfe00000,0xc0000000), sp=0xbfff9f44, free space=2023k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x255d0f]
V [libjvm.so+0x253654]
C 0xffffe420
C [libnet.so+0xdcbb] Java_java_net_SocketOutputStream_socketWrite0+0x1d1
j java.net.SocketOutputStream.socketWrite0(Ljava/io/FileDescriptor;[BII)V+0
j java.net.SocketOutputStream.socketWrite([BII)V+44
j java.net.SocketOutputStream.write(I)V+15
j java.io.DataOutputStream.writeInt(I)V+27
j com.distrobot.common.util.WrappedOutputStream.write([BII)V+16
j java.io.DataOutputStream.write([BII)V+7
j java.io.DataOutputStream.writeUTF(Ljava/lang/String;Ljava/io/DataOutput;)I+426
j java.io.DataOutputStream.writeUTF(Ljava/lang/String;)V+2
j com.distrobot.common.ms.test.SimpleEnvMessage.encode(Lcom/distrobot/common/ms/IEnvMessage;Ljava/io/OutputStream;)V+26
j com.distrobot.common.ms.TcpMessageProducer.sendOnce(Lcom/distrobot/common/ms/IEnvMessage;)Z+30
j com.distrobot.common.ms.TcpMessageProducer.send(Lcom/distrobot/common/ms/IEnvMessage;)V+11
j com.distrobot.common.ms.test.TcpMessageProducerTest.send(Lcom/distrobot/common/ms/ISession;Lcom/distrobot/common/ms/IDestination;
Ljava/lang/String;)V+33
j com.distrobot.common.ms.test.TcpMessageProducerTest.testSocketCache()V+232
v ~StubRoutines::call_stub
V [libjvm.so+0x168c1c]
V [libjvm.so+0x254668]
V [libjvm.so+0x168a4f]
(etc)

Similar Messages

  • MacBook 2006 w/Snow Leopard; HP B210 printer; print problem; error message: One or more components of the HP printing software are corrupted or missing. Reinstalled software but Mac will not cause printer to print.

    ? MacBook 2006 w/Snow Leopard; HP B210 printer; print problem; error message: "One or more components of the HP printing software are corrupted or missing..." Reinstalled software but Mac will not cause printer to print.  My MacBook Pro works fine with same wireless printer.

    Hi ArielAce , thanks for getting back to me!
    I would recommend downloading and running the HP Print and Scan Doctor.
    Please keep me posted!
    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!
    Jamieson
    I work on behalf of HP
    "Remember, I'm pulling for you, we're all in this together!" - Red Green.

  • TS3579 I found this useful because I did not know about the effect of typing in data and that you could only drag to rearrange the data.  I had typed in data before and this had caused problems but restoring defaults did not cause correct dates to show up

    I found this  (TS3579: If the wrong date or time is displayed in some apps on your Mac Learn about If the wrong date or time is displayed in some apps on your Mac) useful because I did not know about the effect of typing in data and that you could only drag to rearrange the data.  I had typed in data before and this had caused problems but restoring defaults did not cause correct dates to show up in Finder. 

    It sounds like there are a couple things going on here.  First check if you have a successful install of SQL Server, then we'll figure out the connection issues.
    Can you launch SQL Server Configuration Manager and check for SQL Server (MSSQLSERVER) if default instance or SQL Server (other name) if you've configured your instance as a named instance.  Once you find this, make sure the service is started. 
    If not started, try to start it and see if it throws an error.  If you get an error, post the error message your hitting.  If the service starts, you can then launch SSMS and try to connect.  If you have a default instance, you can use the machine
    name in the connection dialog.  Ex:  "COWBOYS" where Cowboys is the machine name.  However, if you named the SQL Server instance during install, you'll need to connect using the machine\instance format.  Ex:  COWBOYS\Romo (where Romo
    is the instance name you set during install).
    You can also look at the summary.txt file in the SQL Server setup error logs to see what happened on the most recent install.  Past install history is archived in the log folder if you need to dig those up to help troubleshoot, but the most
    recent one may help get to the bottom of it if there is an issue with setup detecting a prior instance that needs to be repaired.
    Thanks,
    Sam Lester (MSFT)
    http://blogs.msdn.com/b/samlester
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
    "Mark as Answer" and
    "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

  • DOMparser throws IOException when encounters Hungarian Characters

    Hoi!
    I wrote a piece of code that extracts some
    information from an XML document into a vector of Java classes, using the oracle.xml.parser.v2.DOMParser.
    And it worked. Or seemed to work...
    But when I put some articles in the XML file
    in Hungarian, the parser threw IOException.
    If I remplace the Hungarian characters to
    English "equivalents" a -> a etc., it works.
    I don't know. If XML is made up of Unicode characters, what's the problem with it?
    (The hex code of a was E1 in my text editor,
    as I'm using Win NT :(. )
    can I modify the xml prolog somehow?
    I'd rather not write a conversion program
    from a text file to another.
    Any ideas?
    and here's the code:
    DOMParser theParser = new DOMParser();
    XMLStreamToParse = XMLes.class.getResourceAsStream(xmlDocPath);
    theParser.setValidationMode(false);
    try{
    theParser.parse( XMLStreamToParse );
    //this throws IOException
    null

    What are you using as your test client?The test client is WebStone 1.0. WebStone always downloads the whole response, and reports the size of the response in bytes. From this I can see that when the IO exception occurs, webstone is unable to read the whole response, as it reports a smaller size.
    So, I do not think the problem is that the client has prematurely aborted its download. WebStone doesn't work that way. I think something has gone awry on the server side, and this worries me.

  • TS1506 This is not an acceptable solution. Apple please fix this issue. I can't ask my customers to change the format of an email. Seriously?

    This is not an acceptable solution. I cannot ask my customers to change the formatting of their email. Please fix this.

    Is it coming through as a winmail.dat file ? If it is then you could try one of the winmail.dat apps from the store and see if that works with it.
    Or is it coming through as a PDF but isn't downloading, opening or displaying correctly ? If so then is just the one PDF, all PDFs, from one sender ? Have you tried closing the Mail app via the taskbar and seeing if the PDF opens/displays when you re-open the app ? From the home screen (i.e. not with the Mail app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.

  • Essbase Error 1013206 - SetActive Commands are Currently Not Being Accepted

    Hi All,
    I am facing the below error very frequently which is causing the disabling the "Enable connects"on the respective application. It is not happening for all the scheduled processes, just BETWEEN the last cube build or first cube build of the day.
    In Essbase.log server logs observered as below:
    [Fri Sep  9 15:51:51 2011]SERVER NAME/ESSBASE0///Error(1051544)
    message on contacting or from application:
    [Fri Sep  9 15:51:51 2011]SERVER NAME////Error(1013206)
    SetActive Commands are Currently Not Being Accepted
    [Fri Sep  9 15:51:51 2011]SERVER NAME/ESSBASE0///Warning(1051003)
    Error 1013206 processing request [MaxL: Execute] - disconnecting
    Please suggest as It is happening repetedly andcausing the Down time.

    Is it possible that you've issued the command: alter application disable connects ;
    That would cause MaxL to send back that message.
    Per the docs:
    Prevent any user with a permission lower than Application Managers from making connections to the databases that require the databases to be started. This includes starting the databases or performing the ESSCMD SELECT command on the databases. Database connections remain disabled for all databases in the application, until the application setting is re-enabled by the administrator.Link: http://download.oracle.com/docs/cd/E17236_01/epm.1112/esb_tech_ref/maxl_altapp.html
    Is it possible that you issue that command and then try to do things with a username that doesn't have App Manager or higher rights?
    Regards,
    Cameron Lackpour

  • SocketChannel.write() throws IOException instead of returning 0

    I would like your opinion.
    When a send buffer is full in the OS, should a channel's write()
    return 0, or throw an exception? If an exception, should it be the
    same exception (IOException) thrown when truly exceptional events
    happen (e.g, a connection drop)?
    On Win32, SocketChannel.write() internally calls WSASend(). When
    WSASend() returns WSAEWOULDBLOCK, write() throws IOException. I
    think it should return zero instead, or at least throw an exception
    that can be distinguished easily (by other than parsing the
    IOException.getMessage())
    Should I submit a bug?
    Thanks,
    Juan

    The java doc for write() says it should return zero. If you have a simple test case that demonstrates the behavior you describe and it is not already in the bug database, then yes. You should file the bug report.

  • Throws IOException

    What is a best way to write throwing IOException here?
    Can I write try-catch, and after "catch" throw it?
    Is this right?
    I have no idea how to do it with if-clause.
    /** Writes the given apartment data in the file. If the file already
    exists, the old contents are overwritten.
    Parameters:
    apartment - the apartment to be written in the file
    Throws:
    IOException - if other problems arose when handling the file (e.g. the
    file could not be written) */
            public Appartment writeAppartment(Appartment appartment)
                  throws IOException {
                 try {
                    writeStream = new FileOutputStream(filepath);
                    objectStream = new ObjectOutputStream(objectStream);
                    objectStream.writeObject(appartment);
                 } catch (Exception e) {
                   String message ="Writing to file "+filepath+ " failed.";
                   throw new IOException(message);
    }

    Since your method is defined as "throws IOException", why not just get
    rid of the whole try/catch block. Let the caller of writeAppartment
    catch it. You don't seem to be doing anything special with the
    exception when your throwing it, like throwing a custom one, so just
    let java throw it. Plus, what if there is a NullPointerException...it
    would be thrown as an IOException?I see, I haven't understood that when the method is defined as
    "throws IOException", it throws it "automatically".
    So I haven't to do anything.
    But when I call this "throws-method" I have to catch the Exception or
    throw it forward.
    Is that right???
    was meant to be:
    objectStream = new ObjectOutputStream(writeStream);jep, sorry there was an error in that line.

  • Failed to load applet ( Caused by: java.io.IOException: open HTTP connect )

    Sometimes this error occurs :
    load: class applet.OMcsAppletMeetMeConf...
    java.lang.ClassNotFoundException: applet.OMcsAppletMeetMeConf
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed:http://192.168.73.101/mcs/applet/applet/OMcsAppletMeetMeConf.class
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 7 more
    Exception: java.lang.ClassNotFoundException: applet.OMcsAppletMeetMeConf This error occurs sometimes while applet load. In most cases program work normally
    I can not know the cause.
    plz.. help me..
    system info
    - java version : 1.6.0_17
    - browser : ie 8 (but this error also occurs to ie 7, ie 6)
    - html source is :
    <applet id="mm_app" alt="" codebase="/mcs/applet" code="applet.OMcsAppletMeetMeConf"
    width="800px" height="400px" archive="signedApplet.jar">
    </applet>

    namgung0718 wrote:
    Sometimes this error occurs :
    load: class applet.OMcsAppletMeetMeConf...
    java.lang.ClassNotFoundException: applet.OMcsAppletMeetMeConf
    Caused by: java.io.IOException: open HTTP connection failed:http://192.168.73.101/mcs/applet/applet/OMcsAppletMeetMeConf.class
    - html source is :
    <applet id="mm_app" alt="" codebase="/mcs/applet" code="applet.OMcsAppletMeetMeConf"
    width="800px" height="400px" archive="signedApplet.jar">
    </applet> As an aside. Since 'px' is the only valid unit for width and height, they should not be included in the applet element.
    ..This error occurs sometimes while applet load. In most cases program work normally
    I can not know the cause.That applet element combined with the address would imply the JRE was (first) looking for the applet at..
    [http://192.168.73.101/mcs/applet/signedApplet.jar]
    When I try that link in FF, I get the message..
    Network Timeout
    The server at 192.168.73.101 is taking too long to respond.
    plz.. help me..Please take the effort to spell all 6 letters of the word 'please'.

  • Log API: StreamHandler.flush() throws IOException ?

    For some network error reason, my logging stopped working and i noticed this exception in the console:
    java.util.logging.ErrorManager: 2
    java.io.IOException: The specified network name is no longer available
            at java.io.FileOutputStream.writeBytes(Native Method)
            at java.io.FileOutputStream.write(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(Unknown Source)
            at sun.nio.cs.StreamEncoder.flush(Unknown Source)
            at java.io.OutputStreamWriter.flush(Unknown Source)
            at java.util.logging.StreamHandler.flush(Unknown Source)
            at de.icp.logging.RollingFileHandler.publish(Unknown Source)I looked into the javadoc of StreamHandler.flush() and can't find any documented Exception that is thrown. As IOException is not an unchecked exception, this seems to be a javadoc bug, right?
    My "RollingFileHandler extends StreamHandler and my publish() looks like this:
         * Overwrites super.
        public synchronized void publish(LogRecord record) {
            if (!isLoggable(record)) {
                return;
            //check if we need to rotate
            if (System.currentTimeMillis() >= nextCycle) { //next cycle?
                role();
            super.publish(record);
            flush(); //throws IOException ??????
        }//publish()

    Hm ... i think overwriting reportError() is useful:
         * Overwrites super.
         * Reopen log file in case of an error.
        protected void reportError(String msg, Exception ex, int code) {
            super.reportError(msg, ex, code); //standard behaviour of Handler
           //on logging error, try to reopen the logfile:
            openFile();
            LogRecord record = new LogRecord(Level.WARNING, "Log file re-opened due to error:");
            record.setThrown(ex);
            publish(record);
        }//reportError()

  • JarURL.openStream() throws *IOException: no entry name specified*

    <pre>
    I have some code (supplied below) which tries to read contents of a resource
    referred by a URL.
    public class URLTest {
    public static void main(String... args) throws Exception {
    URL u = new URL(args[0]);
    InputStream is = u.openStream();
    // more code goes here:
    If you create a jar file in /tmp/b.jar and run this program as shown below:
    (If your shell treats ! as a special char, then you need to use escape char \ before it)
    java pkg.URLTest <b>jar:file:/tmp/b.jar!/</b>
    it produces the following exception:
    Exception in thread "main" java.io.IOException: no entry name specified
    at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:131)
    at java.net.URL.openStream(URL.java:1007)
    at pkg.URLTest.main(URLTest.java:20)
    But, if you pass the argument as jar:file:/tmp/b.jar!/A.class then it opens a stream
    that points to A.class which is embedded inside b.jar.
    My question is, what is the motivation behind not allowing user to open a stream to
    jar:file:/tmp/b.jar!/ which according to the javadocs of JarURLConnection
    http://java.sun.com/j2se/1.5.0/docs/api/java/net/JarURLConnection.html
    represents a JAR File?
    Thanks,
    Sahoo
    </pre>

    I just also came across this. I don't know the motivation behind it. But it is certainly deliberate.
    This is the source code for JarURLConnection.getInputStream.
    public InputStream getInputStream() throws IOException {
         connect();
         InputStream result = null;
         if (entryName == null) {
              throw new IOException("no entry name specified");
         } else {
              if (jarEntry == null) {
                   throw new FileNotFoundException("JAR entry " + entryName +
                        " not found in " +
                        jarFile.getName());
              result = new JarURLInputStream (jarFile.getInputStream(jarEntry));
         return result;
    }So it will only let you get an InputStream to a file inside the Jar file, not the Jar file itself.
    If you want to do that, then rather than using InputStreams you want to use the JarURLConnection class. My example below shows you how to get at the JarFile and its contents, JarEntry objects,
    URL u = new URL("/tmp/b.jar!/");
    JarURLConnection juc = (JarURLConnection)u.openConnection();
    JarFile jf = juc.getJarFile();
    System.out.println("JarFile: " + jf.getName());
    Enumeration<JarEntry> entries = jf.entries();
    for(JarEntry je = entries.nextElement(); entries.hasMoreElements(); je = entries.nextElement())
         System.out.println("\tJarEntry: " + je.getName());
    }

  • I can use my appleID without any problems for using to download new apps in the app-store or Itunes - Problem: I can´t use my ID at facetime and Imessage - I´d like to add an EMail account on top to my mobile number. My password will not be accepted!!!???

    I can use my appleID without any problems for using to download new apps in the app-store or Itunes - Problem: I can´t use my ID at facetime and Imessage -
    I´d like to add an EMail account on top to my mobile number to use more this services. My password will not be accepted!!!??? I try it and i try it and i try ist, throughout the same problem. Whats on? The user help desk said, i´ve to reset and use the WLAN key new as well as possible - no way!

    Contact the App store for Apple ID help. Their support link is on the right of the App store window
    LN

  • On Windows 7 HttpURLConnection.openConnection() throws IOException

    Hi Team,
    In our application we have a to create httpURLCOnnection (url.openConnection())which works fine on Windows XP but throws IOException on Windows7. Does anybody know which settings need to be enabled on windows 7 to resolve this issue?
    Any response would be appreciated. Thanks in Advance.

    Hello Team,
    I have a specific exception which I get when trying to open a url on Windows 7 with IIS authentication enabled. We get exception when trying to get response code of HTTP Connection
    java.io.IOException: Authentication failure
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    Same code works find on windows XP. Do I need to do any specific settings on Windows7 to work this?
    Thanks in Advance.

  • My Apple ID is not being accepted on my Mac

    My Apple ID is not being accepted on my Mac but is okay on both my other Apple devices.

    Well, what exactly happens and where are you entering it?

  • Is there a way to reset my 4 digit pin? my old one is not being accepted.

    Is there a way to reset my 4 digit pin? my old one is not being accepted.

    The only way to remove a passcode is to restore the device.
    Read:
    Forgot Passcode or Unable to Restore
    (Note that I am a representative of the organization of the above link, which is not endorsed by Apple).

Maybe you are looking for

  • Nokia N8, how do i save messages to mass memory/me...

    cant seem to find an option on my N8 as to where i can save my received texts. used to be in messaging----options----settings----text message or other.    checked both of them and cant find an option to save them to alternative memory???? anyone help

  • Mac Pro with Lion 10.3 'forgets' its optical drives

    I've got a really weird problem here, and I think that I can discount a hardware fault since this problem manifests on two Mac Pros (a 2009 Octo-core and a 2009 Quad-core).  When I start either of these machines up with Snow Leopard, theres no proble

  • Shadow on tooltip

    Hi, I've picked up what I think could be a problem with the tooltip in IE7. I used a PNG with a transparent alpha channel as a background image (to give it a drop shadow) to my tooltip - and it displays fine cross browser. However if I add useEffect:

  • Custom Brushes not showing up in photoshop

    So recently i went on a brush downloading spree and downloaded around 10 brushes. I saved these brushes under Adobe>Adobe Photoshop CC 2014>Presets>Brushes. But these brushes dont show up in photoshop unless i click on them and personally open them.

  • VB script in Classic ASP

    Hi, I'm migrating the VB scripts from Windows 2003 to Windows 2008 server. Server.CreateObject("Scripting.FileSystemObject") is not working? What is the alternate method for this?