views:

257

answers:

2

I have done a fair amount of searches, but couldn't find any thing regarding this topic.

We have a telnet server that does data processing. Logging in telnet has overhead (time), so what I want to do is have a service (WCF) that spawns n number connections and act as the broker between applications/requests and the server.

All of these connections have successfully logged into the server and ready to send commands. Applications can send commands to this service to send to the server and then receive the data from this service. If there are more requests than the number of connections, then those requests will be queued.

I know how to use Threading and events, but how do I know which request to return the data to? LEt's say that there are 9 active requests running, how do I know which request the data returned belong to?

I would appreciate any pointer that can lead me to the right direction.

I am programming using C#

A: 

Rather than simply writing a WCF service, I would look into writing a WCF binding for Telnet that internally handles pooling. Writing a binding to handle your transport and channel level stuff, such as connection pooling, is the appropriate way to solve the problem with WCF. You will gain much greater flexibility this way, in particular, the ability to write multiple services that reuse your telnet binding.

I could go into a lot of detail, but it would likely make for a very large answer. Instead, I'll provide the following links, and offer any additional assistance you need through email. WCF can be hairy and complicated when it is misused, but when it is properly used, it can be an extremely elegant and powerful communications tool.

jrista
A: 

If you don't have an aversion to Enterprise Services, you could create a component to handle the communication to the telnet server which you could configure to use Enterprise Services object pooling.

This will handle the min and max number of pool objects plus object creation timeout and also will queue requests for you. The only "tricky" part would be to ensure that your telnet connections are still valid in your pooled objects.

Alternatively, if you want to stay more closely aligned with WCF then you could implement your own WCF pool as demonstrated in this Pooling Sample.

Tuzo