Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remoting : TCPChannels

Status
Not open for further replies.

jantie

Programmer
Feb 4, 2001
5
0
0
US
Hi all,

I'm working on a set of classes that implements the Entity-Engine pattern. So I have made a data-class (for example Customer), that has some basic properties (Name, Telephone, ...). When I create an instance of my Customer and I set the ID (primary key in the DB), the Customer is ready to be loaded. When the load method of the Customer is called, the customer creates an instance of my Engine Class. This Engine class has a method Load(ByRef myCustomer as Customer) that looks up the data for that Customer in the DB and assign them to the properties of the Customer. This is the scenario works fine when using client/server 2-tier : the Customer and Engine are created on the same machine.

Now I want to use remoting in this design pattern. The engine class is now published as a well-known-service using remoting. So I changed the Load Method of my Customer class. When this method is called it registers a new TCPChannel (this must be done because the Customer is passed ByRef : 2-way communication). It creates an instance of the Engine on the remote computer and it loads the Customer. Then it closes the TCPChannel created above. This works fine, but there is some performance lost (more as I expected).

(And now the questions...)

1) I must register a TCPChannel with a specific port in my Load method of my Customer class. At the end of this method I must close the TCPChannel. When I leave the TCPChannel open, I get an error, the next time the Method Load is called. Because I want to open the TCPChannel with the specific port again. I think this opening/closing of TCPChannels takes some CPU-time. So it would be nice if I could leave the TCPChannel opened, and not trying to open it again. How can I do this?

2) As I said, in my Load method of my Customer class I must open a specific TCPChannel. I think this gives a problem when 2 instances of my Customer Class do this at the same time. So is there a way to check if the TCPChannel is free, or a function that returns a portnumber of a channel that is free?

3) What do you think of this design pattern? Somebody has experience with it?

Thankx in advance,
Jan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top