Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7880309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:06:52+00:00 2026-06-03T04:06:52+00:00

This is my code : connection.setConnectTimeout(5000); ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream()); out.writeObject(to_be_sent); out.flush(); out.close(); int resp_code=connection.getResponseCode();

  • 0

This is my code :

connection.setConnectTimeout(5000);
ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream());
out.writeObject(to_be_sent);
out.flush();
out.close();
int resp_code=connection.getResponseCode();
if(resp_code==200)
{
 JOptionPane.showMessageDialog(obj.frame, "Your Application has been sent Successfully");
}

As you can see I have set the connection timeout to be 5 seconds. I want to know when this connection time exception is thrown and which line throws it. Is it thrown when connection.getResponseCode() does not return anything for 5 seconds?

Edit
Looked up javadocs just now and found out that getResponse code only throws IOException when not able to connect to the server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:06:53+00:00Added an answer on June 3, 2026 at 4:06 am

    Creating the connection and connecting are a multi-step process, some of the parameters won’t have any effect after performing the connection.

    Assuming you are using URLConnection, if you already called connect(), or one of the methods that implicitly perform the connection, it would have no effect at all.

    If the connection was made implicitly with getOutputStream method, the exception will be thrown at your second line of code

    This throws java.net.SocketTimeoutException if the connection cannot be made in the specified time.
    More info about the connect method and setting the connection parameters here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this kind of code for my TCP/IP connection: sock = new Socket(host,
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
considering this code Dim cn As New ADODB.Connection, cn2 As New ADODB.Connection Dim rs
I have this code: //open database connection on the server con = new MySqlConnection(server=localhost;database=GPS;uid=root;pwd=****);
I have searched and found out this code to save data to database, connection
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
This code runs on my local RoR/Windows 7 (64-bit): sql = ActiveRecord::Base.connection() last_pk =
I'm using this code to read the connection string from my app.config file but
C# 2008 I am using this code to test for an internet connection. As
I am trying to run this code: ItemTaxonomy iTaxonomy = from itemTaxonomy in connection.ItemTaxonomy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.