- assigned_to: nobody --> opensebj
Hi,
I've had a look at AckTerm and code, nice ;-)
Anyway heres some code you can merge in to the main tree if you like; it relates to disconnection as I noticed I could continue to try and send data even though the connection was closed.
In ackterm.comms.cs; I expanded the else condition in OnReceivedData to ensure the feedback of disconnection is passed back to the user:
public void OnReceivedData (System.IAsyncResult ar)
...
else
{
// If no data was recieved then the connection is probably dead
System.Console.WriteLine ("Disconnected", StateObject.Socket.RemoteEndPoint);
StateObject.Socket.Shutdown (System.Net.Sockets.SocketShutdown.Both);
StateObject.Socket.Close ();
// Write the Disconnected status to the screen - this is only written from this section once.
this.Invoke(this.RxdTextEvent, new System.String[] { "Disconnected \r\n" });
this.Invoke(this.RefreshEvent);
}
...
------------------------------------------
Then each time a key is pressed in DispatchMessage it checks if the connection is still open:
public void DispatchMessage (System.Object sender, string strText)
{
// Check if scoket is connected
if (this.CurSocket != null)
if (this.CurSocket.Connected == true)
{
...
------------------------------------------
And the else condition to handle when the connection isn't open:
...
}// Socket is not connected
else
{
// Display the Disconnected status in the screen each time a key is pressed.
this.Invoke(this.RxdTextEvent, new System.String[] { "Disconnected \r\n" });
this.Invoke(this.RefreshEvent);
}
}
------------------------------------------------
Cheers,
OpenSebJ