473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Java Socket How do I tell when the connection is closed and how do I open it again

Hey everyone,

I am really rusty on my Java socket programming and am having some confusing problems. I don't need the code debugged(even though it doesn't work). I'm not going to make you dig through all the abstraction layers and such.

Anyways here is my issue. The application sends a request for data to the server and the server responds. However, the server then sends a TCP Fin message to close the connection which I can see through wire shark.

How do I tell when the connection is closed and how do I open it again? Also, what do isClosed, isBound and isCOnnected do in the Java socket class.

My program is crashing because I am trying to write to a closed socket(I think).


However, I get the following weird scenario:

isConnected True
isBound True
isClosed False

This would seem to indicate the socket is still open, but when I write to the socket I get the following Exception:

java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)

Can anyone explain what is going on?

Thanks,

Jon
Jan 14 '08 #1
2 10494
RedSon
5,000 Expert 4TB
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR
Jan 14 '08 #2
r035198x
13,262 8TB
Hey everyone,

I am really rusty on my Java socket programming and am having some confusing problems. I don't need the code debugged(even though it doesn't work). I'm not going to make you dig through all the abstraction layers and such.

Anyways here is my issue. The application sends a request for data to the server and the server responds. However, the server then sends a TCP Fin message to close the connection which I can see through wire shark.

How do I tell when the connection is closed and how do I open it again? Also, what do isClosed, isBound and isCOnnected do in the Java socket class.

My program is crashing because I am trying to write to a closed socket(I think).


However, I get the following weird scenario:

isConnected True
isBound True
isClosed False

This would seem to indicate the socket is still open, but when I write to the socket I get the following Exception:

java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)

Can anyone explain what is going on?

Thanks,

Jon
You can read the specs for the Socket class to find out more about those methods.
Jan 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Gamble | last post by:
I am having problems with long timeouts when connecting to or executing commands in SQL Server 2000 SP3. I am writing an application that will be used on laptops within an environment that is...
0
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages...
0
by: Navin Mishra | last post by:
Sometimes I see connection closed errors: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. at...
4
by: jediknight | last post by:
Hi, I am trying to establish whether I can have a C# socket server and Java socket clients. From all the examples I have seen on the web refer to Java Servers and C# clients. Can anyone point...
2
by: darthghandi | last post by:
I am trying to pass a socket object when an event is signaled. I have successfully bound to a network interface and listened on a port for incoming connection. I have also been able to accept...
20
by: luqman | last post by:
If user login with the login control in ASP.Net 2005 and then just close the browser and then open the browser again, the login status shows, User still Login? Any idea, how to Logout the User...
6
by: billiejoex | last post by:
Hi there. I'm setting up test suite for a project of mine. situations, if the socket is closed on the other end or not. I noticed that I can "detect" such state if a call to socket.read() returns...
6
by: Doug Ferguson | last post by:
I am using a webservice client that was created from a WSDL file in .Net 1.1. The client ALWAYS works the first time I call it. The second call returns one of two exceptions. It either returns...
4
by: Sin Jeong-hun | last post by:
I don't get the message so it's hard to debug that, but some of my clients report that they get "The underlying connection was closed unexpectedly" exception. According to this site (http://...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.