Login  
Search All Forums
Dart Home | PowerTCP Winsock for ActiveX | Custom Development Reply | PowerTCP Winsock for ActiveX Topics | Forums   
AuthorForum: PowerTCP Winsock for ActiveX
Topic: UDP multi-thread issue (error 10057) ?
roofrack
gary.roussak@tyrrellsystems.com

From: Leigh, United Kingdom
Posts: 23
Member Since: 06/08/06
posted January 23, 2007 1:27 PM

Hi,

I am fairly desperate for some help with a Winsock UDP problem in VB6.

I have server and client applications both using Dart UDP controls to communicate with each other privately.

Using a small UDP datagram, at periodic intervals, the client polls the server to see if it is still there (say, every 5 seconds).
Equally, the server checks to see if the client is still alive (say, every 12 seconds).

The server also uses the UDP mechanism to update the client with data updates on an ad-hoc basis.

On both server and client, the UDP control happens to be called sckPriv.

The server also happens to be a web server. Using your own multi-threaded example, when a new HTTP request arrives,
a new Client class is created which handles the request and response, and then is purged shortly after.
The Client class is Instancing=MultiUse and NotPersistable.

This all works fine upto this point.

OK - I now want to add a bit of new functionality.

If a newly created Client class determines that it has received a certain type of GET request,
I want the server to send a short UDP message to my privately connected client.
When I try to do this using my normal sckPriv.Send method and parameters,
to the same IP address and port which I know are ALREADY opened and connected, I'm getting error 10057,
and yet the background connection checking between server and client is still working as normal.

N.B. If I put a Timer on my Listener form and get it to do sckPriv.Send "XYZZY",IPAddr,PortNum every few seconds,
it works fine. If, instead, I trigger the Timer from OUTSIDE the Listener for, the timer fires, but sckPriv.Send
gives error 10057. So I guess this is something to do with the fact that sckPriv has 'gone out of scope'; the Client class,
being created dynamically, is not allowed to make any method calls back to my listener form which declares sckPriv.

Can you think of a way around this (i.e. making a single UDP control with global scope and referenceable by a class) ?

Thanks

Raj

From: Rome, NY, USA
Posts: 389
Member Since: 02/01/06
posted January 23, 2007 4:14 PM

Hi Gary,

"making a single UDP control with global scope and referenceable by a class".
I think you can define a UDP object in the class as public. This will give the class as well as other classes, access to this object.

Now regarding the 10057 error, if the port is already in use for TCP, are you trying to use the same port for UDP? If no, are you opening a port before calling/using the send method?

Thanks,
Raj
roofrack
gary.roussak@tyrrellsystems.com

From: Leigh, United Kingdom
Posts: 23
Member Since: 06/08/06
posted January 23, 2007 6:09 PM

Raj,

The Listener form opens the UDP control, sets its local port, and sets a timeout of zero - everything has been done correctly. Since it is a UDP control, there is no TCP involved, by definition - the HTTP part of the server uses an entirely separate TCP Daemon plus a TCP control for each Client class that gets instantiated.

I am not trying to re-open sckPriv (the UDP control), nor have I closed it and then tried to send something before opening it again. This is what makes it all so mysterious - all I am trying to do is call the Send method on the UDP control that is already being called successfully a dozen or more times elsewhere in the Listener form - but as soon as I try calling Send from another place in the code (another class), I get the 'not connected' error. But I know for sure it IS connected, because there are repeated calls of the Send method going on in the background all the time.

The simple fact is that the Send method doesn't appear to like being invoked from outside the main thread.

I have finished at the office now and am at home sending you this. One thing I noticed when I looked at the release notes on your website was this:

2.8.3.0  Released: 2006-08-28
Product fixes in this release:

  * Corrected threading problems caused when send was called from 2 different places in code (2651)

I'm not sure whether this applies to me and, because I am no longer sat in front of my office PC, I cannot tell which version of DartSock.DLL I am currently using - this will have to wait for about another ten hours! But perhaps this might be the problem ?

Also, I know your next question would probably be to ask for some code to demonstrate the problem. The issue there, Raj, is that it just isn't a practical suggestion: there are probably now several thousand lines of code all in all. I would have to make a copy of it and strip out the irrelevant stuff so it still hangs together. Thats a time-consuming exercise and one which I doubt I can afford, as we have to demonstrate this to a customer on Thursday (UK local time) - hence my desperation!
roofrack
gary.roussak@tyrrellsystems.com

From: Leigh, United Kingdom
Posts: 23
Member Since: 06/08/06
posted January 24, 2007 4:08 AM

Raj,

Bad news - I am already using version 2.8.3.0 of DartSock.DLL.

There is definitely something strange going on here.

How can we take this forward ? We already have a support agreement with you.

Gary
Raj

From: Rome, NY, USA
Posts: 389
Member Since: 02/01/06
posted January 24, 2007 1:29 PM

Hi Gary,

I tried in vain to reproduce the problem, by creating a class, and calling a public UDP component from outside this class, as well as from within. And also tried using multiple threads to call UDP Send, but it worked fine.

If you cannot send in a stripped sample, I will atleast require some steps to reproduce the problem and provide further suggestions. Please reply to me or support@dart.com (with the same subject as on this thread). With your steps/code snippets to reproduce the problem.
-Raj
roofrack
gary.roussak@tyrrellsystems.com

From: Leigh, United Kingdom
Posts: 23
Member Since: 06/08/06
posted January 25, 2007 9:47 AM

Raj,

OK - thanks for trying.

In the meantime, I've had to put in a workaround until I can fathom out what's going wrong - and that is for the Client class to add its UDP datagram and intended recipient into a FIFO which is declared globally in a module. The Listener form comes along every couple of seconds via a timer, checks the FIFO, pops outstanding items off the queue, and sends them. This works - and so relieves the immediate problem - but it shouldn't have to be done this way!

As regards further testing, all I can say is that I will try to find the time to create a stripped down version of the code over the next few days and send it to you if it still doesn't work.

Best regards
Raj

From: Rome, NY, USA
Posts: 389
Member Since: 02/01/06
posted February 1, 2007 7:42 AM

Hi Gary,
Thanks for the sample...
I am working on this, and will get back to you soon with my inputs.
-Raj
Reply | PowerTCP Winsock for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX