RE: Multiple DB sessions and tcp ports limitation
- From: changliw@xxxxxxxxxxxxxxxxxxxx (Charles Wang[MSFT])
- Date: Mon, 10 Dec 2007 09:14:28 GMT
Hi Andrei,
Thanks for your detailed code snippet here.
I performed a test at my side however I could not reproduce your issue. The
following code worked fine at my side:
#include "atldbcli.h"
...
::CoInitialize(NULL);
CDataSource dataSource;
CSession session;
HRESULT hr =
dataSource.OpenFromInitializationString(L"Provider=SQLOLEDB.1;Data
Source=Charles-2k3;Initial Catalog=GT;Integrated Security=SSPI");
for (int i=0; i<1000; i++ ) {
session.Open(dataSource);
//cout<<"Open "<<i<<endl;
session.Close();
//cout<<"Close "<<i<<endl;
}
dataSource.Close();
cout<<"Finished!";
::CoUninitialize();
When I ran TCPView on my client machine, I just saw one record
"MFCConsole.exe:4172 TCP charles-xp:1441 charles-2k3:ms-sql-s
ESTABLISHED" like yours generated when
dataSource.OpenFromInitializationString() was called; when
dataSource.Close() was called, the following record like yours was
generated:
"[System Process]:0 TCP charles-xp:1441 charles-2k3:ms-sql-s TIME_WAIT "
I did not see any messages caused by session.Open and session.Close in
TCPView report. Actually there is only one database connection here, no
short-time repeated connections occur in this program.
I am not sure why you could see so many repeated connection records in
TCPView. If you could provide me (changliw_at_microsoft_dot_com) a
reproducible project, I am very glad for performing further research. Also
if there is anything I misunderstood, please feel free to point out.
My test environment was as following:
Client: Windows XP SP2
Server: Windows Server 2003 SP2
IDE: Visual Studio 2005 SP1
Please feel free to let me know if you have any questions or concerns. It
is my pleasure to be of assistance.
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
.
- References:
- Multiple DB sessions and tcp ports limitation
- From: Andrei Zakharov
- Multiple DB sessions and tcp ports limitation
- Prev by Date: Re: Formatting cells in Excel
- Next by Date: Re: SQL 2005 linked server to Access 97
- Previous by thread: Multiple DB sessions and tcp ports limitation
- Next by thread: Re: SQL 2005 linked server to Access 97
- Index(es):
Relevant Pages
|