?
Solved

close connection to server (.net remoting)

Posted on 2009-02-24
15
Medium Priority
?
706 Views
Last Modified: 2012-05-06
How do I close a client connection to a server so that others can use it?

This is using .net remoting, so the ChannelServices.RegisterChannel to setup the channel and Activator.GetObject used to create a connection to the shared port.

Thank you
0
Comment
Question by:gustierng
  • 8
  • 7
15 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23723116
i dont really understand the question in first place.... close the .net remoting connection
this connection is not the same as sql connection
and secondly when the connection means the clinet object goes out of scope or has completed its processing it just releases its memory

are you getting any kinds of errors due to this on .net remoting
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23724085
0
 

Author Comment

by:gustierng
ID: 23724356
yes. nothing related to databases.  So does unregistering a channel effectively close the connection by making the port available to other users?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23724439
in remoting the port is not used by one connection so there is no point of thinking that once one client is accessing a remoting object other objects cannot access them
secondly you might want to limit the lifetime of the objects created on the server to make optimal use of memoru
and when objects go out of scope the memory as well as connection will be disposed by the garbage collector so you dont have to code an extra step of unregistering the ports
0
 

Author Comment

by:gustierng
ID: 23731543
My main problem at the moment is a RemotingException

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24175257.html
0
 

Author Comment

by:gustierng
ID: 23744158
Hi
I followed your advice but now I am getting a SocketException:

I start up the server which is updated in realtime on a single port.   Users read data on a second port.  The first time I run the client it works fine.  If I close the app and run the client again I get:

SocketException:
No connection could be made because the target machine actively refused it

I have not even got to the stage of testing multiple users over this port.  I am using a singleton, tcp.

0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23746715
first time the remoting channel is registered correctly and everything runs correctly
but when you run the client second time the previous channel/port to which the registered does not allow you to register it again

you will have to find a way to deregister the port and then regiester it again
0
 

Author Comment

by:gustierng
ID: 23747334
that's a good idea, i'll try bthat and let you know.

What if other users are using that port?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23747354
actually its not that port
you dont close the port its the channel that you register on the client machine
port/socket on the server is not affected
0
 

Author Comment

by:gustierng
ID: 23747614
ok,  so is there a way to refer to a channel by port rather than name?

TcpChannel tcpChannel;
tcpChannel = (TcpChannel)ChannelServices.GetChannel(theChannelName)
if (tcpChannel!= null)
{
      ChannelServices.UnregisterChannel(tcpChannel);
}

Or, is this the way it iss done?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 23752520
havent used this in .net 20 or above so cannot say this
sorry
0
 

Author Comment

by:gustierng
ID: 23755931
how do you close the channel?
0
 

Author Comment

by:gustierng
ID: 23757021
that is the same way I have posted above.  You need to check the channel exists
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 1500 total points
ID: 23757228
i really cant help with the code i can give you the suggestions but you might have to work thigs at your end
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question