Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Closing socket on ClientConnection.disconnect
Closing socket on ClientConnection.disconnect [message #23539] Wed, 03 April 2002 20:50 Go to next message
Eclipse UserFriend
The ClientConnection.disconnect() methods needs to close the socket,
otherwise the socket remains open until the Eclipse client is shutdown
even though the server has ended (the server end of the socket remains in
finished wait state, waiting for the client to end the connection.) The
following code accomplishes this:

public void disconnect()
{
if (_isConnected)
{
_dataStore.setConnected(false);

if (_isRemote)
{
_commandHandler.command(_dataStore.find(_dataStore.getRoot() ,
DE.A_NAME, "Exit"),
_dataStore.getHostRoot(),
// true);
false);
_receiver.finish();
}

_commandHandler.finish();

try
{
Thread.currentThread().sleep(200);
}
catch (InterruptedException e)
{
System.out.println(e);
}

_updateHandler.finish();
_dataStore.flush();

try {
_theSocket.close();
} catch (IOException e) {
// Log the error ???
}

_isConnected = false;
}
}

Don Yantzi
Software Developer
IBM Toronto Lab
Re: Closing socket on ClientConnection.disconnect [message #23625 is a reply to message #23539] Wed, 03 April 2002 21:55 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Don,

I'll put this fix in.

Dave

yantzi@ca.ibm.com wrote:

> The ClientConnection.disconnect() methods needs to close the socket,
> otherwise the socket remains open until the Eclipse client is shutdown
> even though the server has ended (the server end of the socket remains in
> finished wait state, waiting for the client to end the connection.) The
> following code accomplishes this:
>
> public void disconnect()
> {
> if (_isConnected)
> {
> _dataStore.setConnected(false);
>
> if (_isRemote)
> {
> _commandHandler.command(_dataStore.find(_dataStore.getRoot() ,
> DE.A_NAME, "Exit"),
> _dataStore.getHostRoot(),
> // true);
> false);
> _receiver.finish();
> }
>
> _commandHandler.finish();
>
> try
> {
> Thread.currentThread().sleep(200);
> }
> catch (InterruptedException e)
> {
> System.out.println(e);
> }
>
> _updateHandler.finish();
> _dataStore.flush();
>
> try {
> _theSocket.close();
> } catch (IOException e) {
> // Log the error ???
> }
>
> _isConnected = false;
> }
> }
>
> Don Yantzi
> Software Developer
> IBM Toronto Lab
Re: Closing socket on ClientConnection.disconnect [message #23668 is a reply to message #23625] Wed, 03 April 2002 22:02 Go to previous message
Eclipse UserFriend
One more minor change, this code needs to be conditioned for _theSocket ==
null (as is the case for localConnect())

if (_theSocket != null) {
try {
_theSocket.close();
} catch (IOException e) {
//e.printStackTrace();
}
_theSocket = null;
}
Previous Topic:SWT
Next Topic:CDT driver 20020408 available for download
Goto Forum:
  


Current Time: Sun Jun 08 11:29:12 EDT 2025

Powered by FUDForum. Page generated in 0.15408 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top