views:

103

answers:

2

I am new to network programming. I want to create a network blocker. which blocks an IP from the LAN. How is this possible in C#?

+1  A: 

In WCF I know this code works

    /// <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;
        }
    }
kenny
This should be helpful when Tarun figures out how to break down the problem.
Karl the Pagan
A: 

You would be mimicking what a firewall does, which is insert itself into the tcp stack to monitor all inbound traffic. Installing a firewall is definately the easiest way, otherwise start looking into using a Layered Service Provider

PaulG