2010-07-16 113 views
1

我有2個問題給你。C#ping特定的端口和代理憑證

我創建一個應用程序的聊天,依賴於Jabber,女巫是我的服務器端口5222服務器端的東西。

港口平

如何通過端口5222 Ping通服務器,並檢查,看看它開放和響應。

喜歡的東西Ping.Once(Settings.Defualt.ChatServerDomain,Settings.Defualt.ChatServerPort);

代理身份

在我的工作我的應用程序不登錄,因爲我們運行代理服務器,在IE瀏覽器,你可以設置代理服務器設置女巫允許所有的普通應用程序連接一擲,但我的應用程序不使用這些設置。

所以我需要做的是創建一個小檢查器,看看是否在代理服務器後面,如果我們顯示一個窗口來驗證用戶憑據。並將應用程序綁定到他們的憑據,以便在應用程序打開時驗證任何請求。

這就是我的意思是在編碼條款

if(ProxyAuthRequired()) 
{ 
    ProxyAuthWindow ProxyAuthWindow = new ProxyAuthWindow(); 
    CurrentWindow.Enable = false; 
    /* 
    * Within the Form ProxyAuthWindow, This will callback to my main controller after 
    * The auth is checked and ok, This is what i do not know how to do 
    */ 
    ProxyAuthWindow.Show(); //Ask for the credentials and check the port inside here 
} 
+1

請把它分成兩個問題。 – 2010-07-16 09:24:41

+0

那麼真的有同樣的問題,連接到服務器,並認證到服務器。我不介意將它們分開 – RobertPitt 2010-07-16 09:28:44

回答

3
  1. 對於平:嘗試Ping

  2. 這裏是你怎麼能check and set the proxy憑據。

+0

Ping不接受端口號:( – RobertPitt 2010-07-16 10:38:46

+2

@Robert:我想你將不得不使用'System.Net.Socket',例如'TcpClient'類,* try *連接到特定的ip /端口,看看你是否能夠連接或得到一個異常。 – 2010-07-16 10:55:55

+0

感謝allot,這正是我需要:) – RobertPitt 2010-07-16 11:10:12