远程服务器连接检查 [英] Remote server connection check

查看:121
本文介绍了远程服务器连接检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我正在VS .NET 2008下用C#开发应用程序.为此,我必须建立与远程服务器的连接,并且必须将文件从服务器下载到我的系统.

但是我希望在建立新连接之前,可能已经在其他模块等中建立了连接.我想检查是否已建立连接,它会告诉我连接已建立"的状态,以便我可以使用以前的连接进行下载.

在此先感谢.

问候

Nauman



I am developing an application in C# under VS .NET 2008. For this I have to establish a connection to the remote server and have to download the files from server to my system.

But I want that before making a new connection, it is possible that connection is already established in other modules etc. I want to check that if connection is already established it tell me the status that "connection is already established", so that I can use previous connection for downloading.

Thanks in Advance.

Regards

Nauman

推荐答案

如何...

How about...

using System.Net.NetworkInformation;

IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
TcpConnectionInformation[] tcpInfoList = properties.GetActiveTcpConnections();

foreach (TcpConnectionInformation info in tcpInfoList)
{
    // Code to check on the info object for your remote server details
}


出于上述需要,您需要使用连接池.

程序员天堂的以下文章可能会帮助您理解和实现连接池.

http://www.programmersheaven.com/user/sreeharikv/blog/295 -Connection-Pooling-in-DotNet/ [
For your above needs you need to use connection pooling.

Following article from programmers heaven may help you to understand and implement connection pooling.

http://www.programmersheaven.com/user/sreeharikv/blog/295-Connection-Pooling-in-DotNet/[^]


这篇关于远程服务器连接检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆