Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Works on Windows but timeout on linux

843790May 14 2009 — edited May 21 2009
I have a problem with the code below. It perfectly works under Windows, but I am getting a timeout under Linux. I am not sure why. Any ideas?

One more thing: Under Liunx It fails when I am testing it using port 1935. However, if I test it with port 110, it works. On Windows it works with both ports (110 & 1935).

Thanks you!

Gustavo

            try {

                theSocket = new Socket(Address,Port);
                theSocket.setSoTimeout(Timeout);

              try {
                    BufferedReader inFromServer = new BufferedReader(
                            new InputStreamReader(theSocket.getInputStream()));

                    PrintWriter outToServer = new PrintWriter(new BufferedWriter(
                            new OutputStreamWriter(theSocket.getOutputStream())), true);

                    outToServer.println((char)13);
                    messageReceived = inFromServer.readLine();

                    TmpPage = messageReceived;

                }

                catch(IOException e) {
                    if (status == 1){
                        ErrorDescription = ErrorDescription+"ERRTEL01 Error in TELNETMonitor Thread: "+e.getMessage();
                    }else{
                        ErrorDescription = "ERRTEL01 Error in TELNETMonitor Thread: "+e.getMessage();
                    }

                    status = 1;
                 }
                finally {
                    theSocket.close();
                }
            }
            catch(UnknownHostException e) {
                if (status == 1){
                    ErrorDescription = ErrorDescription+"ERRTEL03 Error in TELNETMonitor Thread (INVALID HOST): "+e.getMessage();
                }else{
                    ErrorDescription = "ERRTEL03 Error in TELNETMonitor Thread (INVALID HOST): "+e.getMessage();
                }

                status = 1;

            }
            catch(ConnectException e) {
                if (status == 1){
                    ErrorDescription = ErrorDescription+"ERRTEL04 Error in TELNETMonitor Thread (THE HOST DOESN'T RUN A SERVER ON THE SPECIFIED PORT): "+e.getMessage();
                }else{
                    ErrorDescription = "ERRTEL04 Error in TELNETMonitor Thread (THE HOST DOESN'T RUN A SERVER ON THE SPECIFIED PORT): "+e.getMessage();
                }

                status = 1;
            }
            catch(IOException e) {
                if (status == 1){
                    ErrorDescription = ErrorDescription+"ERRTEL01 Error in TELNETMonitor Thread: "+e.getMessage();
                }else{
                    ErrorDescription = "ERRTEL01 Error in TELNETMonitor Thread: "+e.getMessage();
                }

                status = 1;
            }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2009
Added on May 14 2009
11 comments
416 views