2009-10-01 44 views
0

我是網絡編程的新手。我想創建一個網絡攔截器。阻止來自局域網的IP。這在C#中如何實現?C#中的網絡IP阻塞程序

+5

安裝防火牆。 – ryeguy 2009-10-01 14:43:30

+3

從一個不那麼雄心勃勃的項目開始(我建議檢查你的電子郵件或一個天真的Web服務器作爲一個初學者項目)。 – 2009-10-01 15:00:39

回答

1

在WCF我知道這個代碼工作

/// <summary> 
    /// Returns the client IP 
    /// </summary> 
    public static string ClientIP 
    { 
     get 
     { 
      // determine IP address takes < 1ms 
      OperationContext context = OperationContext.Current; 
      MessageProperties messageProperties = context.IncomingMessageProperties; 
      RemoteEndpointMessageProperty endpointProperty = 
       messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; 
      return endpointProperty.Address; 
     } 
    } 
+0

當Tarun找出如何解決問題時,這應該會很有幫助。 – 2009-10-01 15:08:57

0

你會被模仿防火牆做什麼,這是插入到自己的TCP協議棧,以監控所有入站流量。安裝防火牆肯定是最簡單的方法,否則開始考慮使用Layered Service Provider