| Dart Home | PowerTCP Sockets for .NET | Custom Development | Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
| Author | Forum: PowerTCP Sockets for .NET (Secure and Standard) Topic: Two events with UDP? |
| cambler From: Redmond, WA USA Posts: 102 Member Since: 04/14/03 |
posted April 25, 2006 7:23 PM When listening on a UDP connection, I'm getting two events firing. The first is the expected on, with the data I'm anticipating, and all seems well. The second is an exception, where e.Exception is not null. The exception speaks of the connection being forcibly closed at the sender - something that doesn't make much sense in UDP-land... Any clue what this second event is? If I protect my code by ignoring the exception, all works fine. But who wants two events when there should only be one? The code for my receiver: private void udpSync_EndReceive(object sender, Dart.PowerTCP.SslSockets.DatagramEventArgs e) { if (e.Exception == null) { string sSync = e.Datagram.ToString(); int pos = Convert.ToInt32(sSync); // HERE IS WHERE I DO SOMETHING WITH "pos" } // Start receiving next this.udpSync.BeginReceive(this.syncBuffer); } |
| Raj From: Rome, NY, USA Posts: 389 Member Since: 02/01/06 |
posted April 27, 2006 11:34 AM Hi Chris, I have not been able to replicate the behavior at my end. Can you please provide me some replicating steps? The error that you are getting surely means that connection was disconnected. It might be that your app sent some data and is now listening, when nothing arrived, it closed the port. But this is just my assumption, if you can send me replicating steps. I would be in a better position to comment on the issue. Adding to this: With the .NET components, when an unhandled exception occurs within an event handler, the way the component handles it is unusual. What happens is that the event fires again, this time with the e.Exception set to the exception that occurred in the event handler. To prevent this, there should always be error handling surrounding all code in the event handler. So, it seems to me that something in your code is raising an exception, therefore, the event fires again. You should try adding try...catch in the event handler, and see if the event still fires again. Let me know if you have further questions. Regards, Raj |
| Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|