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 (OleDbConnection) 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 GetDbConnFromPool 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.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Data.OleDb;
using System.Windows.Forms;
namespace PoolManager
{
public class PoolServer : MarshalByRefObject
{
private int iConnCnt;
public PoolServer()
{
try
{
TcpChannel channel = new TcpChannel(5000);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(PoolServer),
"MilenasDbPool",
WellKnownObjectMode.Singleton
);
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
public OleDbConnection NewConnFromPool()
{
iConnCnt++;
OleDbConnection dbNewConn;
dbNewConn = new OleDbConnection("Provider=MSDAORA.1;Password=pwd;U ser
ID=usr;Data Source=DATABASE;Pooling=true");
return dbNewConn;
}
public void DisposeConn(OleDbConnection dbConn)
{
dbConn.Dispose();
iConnCnt--;
}
}
}
////////////////////////////////////////////////////////////////////////////
///////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////
My Client Code is Below
public class PoolClient
{
public PoolClient(string host,string port)
{
try
{
string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";
TcpChannel chn = new TcpChannel();
ChannelServices.RegisterChannel(chn);
PoolServer plMan = (PoolServer)Activator.GetObject(
typeof(PoolServer),strDest);
OleDbConnection refConnFromPool = plMan.NewConnFromPool();
MessageBox.Show(refConnFromPool.ConnectionString);
refConnFromPool.Open();
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
}
Helps will be appreciated..
Ahmet. 2 3013
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 (OleDbConnection) 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 GetDbConnFromPool 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.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Data.OleDb;
using System.Windows.Forms;
namespace PoolManager
{
public class PoolServer : MarshalByRefObject
{
private int iConnCnt;
public PoolServer()
{
try
{
TcpChannel channel = new TcpChannel(5000);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceTyp e(typeof(PoolServer),
"MilenasDbPool",
WellKnownObjectMode.Singleton
);
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
public OleDbConnection NewConnFromPool()
{
iConnCnt++;
OleDbConnection dbNewConn;
dbNewConn = new OleDbConnection("Provider=MSDAORA.1;Password=pwd;U ser ID=usr;Data Source=DATABASE;Pooling=true");
return dbNewConn;
}
public void DisposeConn(OleDbConnection dbConn)
{
dbConn.Dispose();
iConnCnt--;
}
}
} //////////////////////////////////////////////////////////////////////////// ///////////////////////
//////////////////////////////////////////////////////////////////////////// ///////////////////////
My Client Code is Below public class PoolClient
{
public PoolClient(string host,string port)
{
try
{
string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";
TcpChannel chn = new TcpChannel();
ChannelServices.RegisterChannel(chn);
PoolServer plMan = (PoolServer)Activator.GetObject(
typeof(PoolServer),strDest);
OleDbConnection refConnFromPool = plMan.NewConnFromPool();
MessageBox.Show(refConnFromPool.ConnectionString) ;
refConnFromPool.Open();
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
}
Helps will be appreciated..
Ahmet.
that solved the problem.
thanks.
"Scott C. Wagner" <sw*******@SPAMseisint.com> wrote in message
news:3F**************@SPAMseisint.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 (OleDbConnection) 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 GetDbConnFromPool 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.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Data.OleDb;
using System.Windows.Forms;
namespace PoolManager
{
public class PoolServer : MarshalByRefObject
{
private int iConnCnt;
public PoolServer()
{
try
{
TcpChannel channel = new TcpChannel(5000);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceTyp e(typeof(PoolServer),
"MilenasDbPool",
WellKnownObjectMode.Singleton
);
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
public OleDbConnection NewConnFromPool()
{
iConnCnt++;
OleDbConnection dbNewConn;
dbNewConn = new OleDbConnection("Provider=MSDAORA.1;Password=pwd;U ser ID=usr;Data Source=DATABASE;Pooling=true");
return dbNewConn;
}
public void DisposeConn(OleDbConnection dbConn)
{
dbConn.Dispose();
iConnCnt--;
}
}
}
///////////////////////////////////////////////////////////////////////////
/ ///////////////////////
///////////////////////////////////////////////////////////////////////////
/ ///////////////////////
My Client Code is Below public class PoolClient
{
public PoolClient(string host,string port)
{
try
{
string strDest = "tcp://" + host + ":" + port + "/MilenasDbPool";
TcpChannel chn = new TcpChannel();
ChannelServices.RegisterChannel(chn);
PoolServer plMan = (PoolServer)Activator.GetObject(
typeof(PoolServer),strDest);
OleDbConnection refConnFromPool = plMan.NewConnFromPool();
MessageBox.Show(refConnFromPool.ConnectionString) ;
refConnFromPool.Open();
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message);
}
}
}
Helps will be appreciated..
Ahmet. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
by: Rich |
last post by:
Can anyone suggest a good (current) tutorial on how to do basic
remoting with C# (2005 express edition)?
|
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...
|
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.
...
|
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...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |