Methode von Mircosoft funktioniert nicht



  • Hi,

    ich bin momentan dabei ein kleines Netzwerkprogramm zu schreiben.
    Dazu benutze ich die Klassen TcpCLient und TcpListener.
    Die klappen auch wunderbar, bis auf eine Methode.

    Client.Connected
    

    Dieser Wert gibt an, ob der Client momentan verbunden ist.
    Wenn ich jetzt von 2 verbundenen CLients einen beeden, gilt der
    andere immer noch als Connected, obwohl es unmöglich ist.

    Diese 2 hatten das gleiche Problem, aber ihre Lösung( für Delphi)
    klappt in C# nicht.
    http://www.delphipraxis.net/topic69744.html

    Weiß eine weiter?



  • Bevor man rummotzt wäre Doku lesen ne Idee. Hier mal was aus der MSDN Lib:

    The Connected property gets the connection state of the Client socket as of the last I/O operation. When it returns false, the Client socket was either never connected, or is no longer connected.

    Because the Connected property only reflects the state of the connection as of the most recent operation, you should attempt to send or receive a message to determine the current state. After the message send fails, this property no longer returns true. Note that this behavior is by design. You cannot reliably test the state of the connection because, in the time between the test and a send/receive, the connection could have been lost. Your code should assume the socket is connected, and gracefully handle failed transmissions.


Anmelden zum Antworten