473,799 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting Using TcpChannel (Urgent)

Hi;

I am trying to make a server that handles db connection pool.
Clients use TcpChannel to make a call to this server and get one
database connection (OleDbConnectio n) from pool.

But when I try to connect to server using TcpChannel,
I get this message "Only one usage of each socket address (protocol/network
adress /port)"
is normally permitted.
But then my call to GetDbConnFromPo ol succees and I get connection from
server.
Why I get the message above ?

Below you can see my server and client codes
Server code
using System;

using System.Runtime. Remoting;

using System.Runtime. Remoting.Channe ls;

using System.Runtime. Remoting.Channe ls.Tcp;

using System.Data.Ole Db;

using System.Windows. Forms;

namespace PoolManager

{

public class PoolServer : MarshalByRefObj ect

{

private int iConnCnt;

public PoolServer()

{

try

{

TcpChannel channel = new TcpChannel(5000 );

ChannelServices .RegisterChanne l(channel);

RemotingConfigu ration.Register WellKnownServic eType(typeof(Po olServer),

"MilenasDbPool" ,

WellKnownObject Mode.Singleton

);

}

catch(System.Ex ception eSysExc)

{

MessageBox.Show (eSysExc.Messag e);

}

}
public OleDbConnection NewConnFromPool ()

{

iConnCnt++;

OleDbConnection dbNewConn;

dbNewConn = new OleDbConnection ("Provider=MSDA ORA.1;Password= pwd;User
ID=usr;Data Source=DATABASE ;Pooling=true") ;

return dbNewConn;

}
public void DisposeConn(Ole DbConnection dbConn)

{

dbConn.Dispose( );

iConnCnt--;

}

}

}

////////////////////////////////////////////////////////////////////////////
///////////////////////

////////////////////////////////////////////////////////////////////////////
///////////////////////

My Client Code is Below

public class PoolClient

{

public PoolClient(stri ng host,string port)

{

try

{

string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";

TcpChannel chn = new TcpChannel();

ChannelServices .RegisterChanne l(chn);

PoolServer plMan = (PoolServer)Act ivator.GetObjec t(

typeof(PoolServ er),strDest);

OleDbConnection refConnFromPool = plMan.NewConnFr omPool();

MessageBox.Show (refConnFromPoo l.ConnectionStr ing);

refConnFromPool .Open();

}

catch(System.Ex ception eSysExc)

{

MessageBox.Show (eSysExc.Messag e);

}

}

}

Helps will be appreciated..

Ahmet.
Nov 15 '05 #1
2 3049
You're registering the remoting channel in the constructor of the object
that is being created. Therefore, you're attempting to register the
channel every time a client requests the object be created.

HTH,
Scott Wagner
Seisint, Inc.

Ahmet AKGUN wrote:
Hi;

I am trying to make a server that handles db connection pool.
Clients use TcpChannel to make a call to this server and get one
database connection (OleDbConnectio n) from pool.

But when I try to connect to server using TcpChannel,
I get this message "Only one usage of each socket address (protocol/network
adress /port)"
is normally permitted.
But then my call to GetDbConnFromPo ol succees and I get connection from
server.
Why I get the message above ?

Below you can see my server and client codes
Server code
using System;

using System.Runtime. Remoting;

using System.Runtime. Remoting.Channe ls;

using System.Runtime. Remoting.Channe ls.Tcp;

using System.Data.Ole Db;

using System.Windows. Forms;

namespace PoolManager

{

public class PoolServer : MarshalByRefObj ect

{

private int iConnCnt;

public PoolServer()

{

try

{

TcpChannel channel = new TcpChannel(5000 );

ChannelService s.RegisterChann el(channel);

RemotingConfig uration.Registe rWellKnownServi ceType(typeof(P oolServer),

"MilenasDbPool ",

WellKnownObjec tMode.Singleton

);

}

catch(System.E xception eSysExc)

{

MessageBox.Sho w(eSysExc.Messa ge);

}

}
public OleDbConnection NewConnFromPool ()

{

iConnCnt++;

OleDbConnectio n dbNewConn;

dbNewConn = new OleDbConnection ("Provider=MSDA ORA.1;Password= pwd;User
ID=usr;Data Source=DATABASE ;Pooling=true") ;

return dbNewConn;

}
public void DisposeConn(Ole DbConnection dbConn)

{

dbConn.Dispose ();

iConnCnt--;

}

}

}

////////////////////////////////////////////////////////////////////////////
///////////////////////

////////////////////////////////////////////////////////////////////////////
///////////////////////

My Client Code is Below

public class PoolClient

{

public PoolClient(stri ng host,string port)

{

try

{

string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";

TcpChannel chn = new TcpChannel();

ChannelService s.RegisterChann el(chn);

PoolServer plMan = (PoolServer)Act ivator.GetObjec t(

typeof(PoolSer ver),strDest);

OleDbConnectio n refConnFromPool = plMan.NewConnFr omPool();

MessageBox.Sho w(refConnFromPo ol.ConnectionSt ring);

refConnFromPoo l.Open();

}

catch(System.E xception eSysExc)

{

MessageBox.Sho w(eSysExc.Messa ge);

}

}

}

Helps will be appreciated..

Ahmet.


Nov 15 '05 #2

that solved the problem.
thanks.
"Scott C. Wagner" <sw*******@SPAM seisint.com> wrote in message
news:3F******** ******@SPAMseis int.com...
You're registering the remoting channel in the constructor of the object
that is being created. Therefore, you're attempting to register the
channel every time a client requests the object be created.

HTH,
Scott Wagner
Seisint, Inc.

Ahmet AKGUN wrote:
Hi;

I am trying to make a server that handles db connection pool.
Clients use TcpChannel to make a call to this server and get one
database connection (OleDbConnectio n) from pool.

But when I try to connect to server using TcpChannel,
I get this message "Only one usage of each socket address (protocol/networkadress /port)"
is normally permitted.
But then my call to GetDbConnFromPo ol succees and I get connection from
server.
Why I get the message above ?

Below you can see my server and client codes
Server code
using System;

using System.Runtime. Remoting;

using System.Runtime. Remoting.Channe ls;

using System.Runtime. Remoting.Channe ls.Tcp;

using System.Data.Ole Db;

using System.Windows. Forms;

namespace PoolManager

{

public class PoolServer : MarshalByRefObj ect

{

private int iConnCnt;

public PoolServer()

{

try

{

TcpChannel channel = new TcpChannel(5000 );

ChannelService s.RegisterChann el(channel);

RemotingConfig uration.Registe rWellKnownServi ceType(typeof(P oolServer),

"MilenasDbPool ",

WellKnownObjec tMode.Singleton

);

}

catch(System.E xception eSysExc)

{

MessageBox.Sho w(eSysExc.Messa ge);

}

}
public OleDbConnection NewConnFromPool ()

{

iConnCnt++;

OleDbConnectio n dbNewConn;

dbNewConn = new OleDbConnection ("Provider=MSDA ORA.1;Password= pwd;User
ID=usr;Data Source=DATABASE ;Pooling=true") ;

return dbNewConn;

}
public void DisposeConn(Ole DbConnection dbConn)

{

dbConn.Dispose ();

iConnCnt--;

}

}

}


///////////////////////////////////////////////////////////////////////////

/
///////////////////////


///////////////////////////////////////////////////////////////////////////

/
///////////////////////

My Client Code is Below

public class PoolClient

{

public PoolClient(stri ng host,string port)

{

try

{

string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";

TcpChannel chn = new TcpChannel();

ChannelService s.RegisterChann el(chn);

PoolServer plMan = (PoolServer)Act ivator.GetObjec t(

typeof(PoolSer ver),strDest);

OleDbConnectio n refConnFromPool = plMan.NewConnFr omPool();

MessageBox.Sho w(refConnFromPo ol.ConnectionSt ring);

refConnFromPoo l.Open();

}

catch(System.E xception eSysExc)

{

MessageBox.Sho w(eSysExc.Messa ge);

}

}

}

Helps will be appreciated..

Ahmet.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2804
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server in C# and we're using remoting for client to server communication.
15
5753
by: Sharon | last post by:
I’m trying to build a generic Publisher-Subscriber that will work over the net, so I’m using the Remoting. I wish that the subscriber user will be notify about the messages sent by the remote publisher, so I used delegate that the user will be able to set on it his own function for that purpuse. The trouble is that this delegate must not be static because there may be many subscribers, and each subscriber may have different...
4
3118
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give it a go). What I want to do is this: Have a server instance of the program, this server instance will receive communication from client programs (as demonstrated in the AddMessage()
9
2102
by: Nak | last post by:
Hi there, I have been messing around with remoting in an attempt to create a "shared application" as mentioned in another thread by that name. I have created a singleton object just like the example in the 101 VB.NET examples. It works great, only 1 instance ever gets created and is shared by each client. I have a few questions though, * Can the singleton contain events? In such a way that when the
4
2267
by: Sharon | last post by:
Hi, I'm using the remoting, and I have a remoting object that has a public event that other processes should register to it. But when the client process is registering to the remote event, it throw the following exception: System.Runtime.Serialization.SerializationException {“Cannot find the assembly Tester, Version=1.0.2164.27180, Culture=neutral, PublicKeyToken=null.”}
4
6650
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
7
2176
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am trying to see if I can call a Library remotely. The library contains a Form that I want to display then pass back some data to user that called this form remotely. I have it working some-what. I am able to call form remotely and return data to client but somewhere after closing remote form and returning data - I get a Windows exception -
3
3747
by: Adhal | last post by:
Hi, I am using remoting to pass in parameters from new launches of an application. So basically I have only one instance of the application and I am using remoting to pass the parameters. The problem is as follows: I can remote call the first few times, but then I get the "No connection could be made because target machine actively refused it 127.0.0.1:8084"
0
1580
by: senpark15 | last post by:
Hi EveryBody, I am developing .net remoting application.I have Created server and client application. Server has installed on Two Pc's and cliient have to connect two Pc's and do some functions. Its working Fine on local machine . But when i tried to connect two PC's, its through an remoting exception This is my server code: Dictionary<string, object> props = new Dictionary<string, object>(); props = "Full";
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.