locked
How do you detect if the socket has been closed?

    Question

  • Hello guys.

    Is there any way for me to check if a datagram socket is still opened before sending info to the remote server? I'm binding the datagramsocket to a specific port and opening it before writing the info I with the DataWriter object. However, I've noticed that sometimes I end up getting an exception which says that the object has been close (it happens in the storeAsync line when I try to send several messages at once...)

    var writer = new Windows.Storage.Streams.DataWriter(this.socket.outputStream);
    writer.writeString(msg);
    writer.storeAsync()
                        .done(function () {
                            writer.detachBuffer();
                        });

    thanks


    Luis Abreu

    Monday, April 16, 2012 12:29 PM

Answers

All replies

  • I do not believe so.  You can trap the exception and retry however.

    -Jeff


    Jeff Sanders (MSFT)

    Tuesday, April 17, 2012 2:27 PM
    Moderator
  • Hello Jeff.

    Yes, that is what I'm doing at the moment...just checking to see if I had missed something.


    Luis Abreu

    Wednesday, April 18, 2012 9:07 AM