2012-02-21 35 views
2

我開發一個HTTP偵聽器來訪問遠程過程。示例代碼片段:HTTPS偵聽器.NET未能在端口443

HttpListener listener = new HttpListener(); 
listener.Prefixes.Add("https://*:443/"); 
listener.Start(); 
Console.WriteLine("Listening..."); 
for (; ;) 
{ 
HttpListenerContext ctx = listener.GetContext(); 
new Thread(new Worker(ctx).ProcessRequest).Start(); 
} 

這是正常工作如果我使用端口8080,但未能在端口443上唯一的例外是

System.Net.HttpListenerException was unhandled 
Message=The process cannot access the file because it is being used by another process 
+0

請在未來縮進代碼。這會讓其他人更容易閱讀你的代碼。 – tr9sh 2012-02-21 16:41:42

回答

3

請確保沒有任何其他網站(在IIS或Apache)通過SSL端口443提供服務​​?這應該是報告問題的常見原因。

您可以嘗試一些其他的端口,看是否相同的異常是由HttpListener對象拋出。

+0

嗨Karthick,非常感謝您的信息。我用命令netstat -n -o -a看到使用的端口列表,發現Skype是使用該端口。移除後問題已解決。 – Pra 2012-02-21 09:26:46