Link to home
Start Free TrialLog in
Avatar of Natural_Demon
Natural_DemonFlag for Spain

asked on

Build in mini firewall

whit a code like this.

how can i filter ip's?
and set a range on witch i would like to listen too.






private void Listener()
        {
            IPEndPoint from = new IPEndPoint(IPAddress.Any, this.Port);
 
            while (true)
            {
                try
                {
                    byte[] datagram = Client.Receive(ref from);
                    string result = Encoding.UTF8.GetString(datagram);
                    ReceiveString(result);
                }
                catch
                {
                }
            }
        }

Open in new window

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

you can now who the frame came from by using reading the .Address property:


                 try
                {
                    byte[] datagram = Client.Receive(ref from);
                    string result = Encoding.UTF8.GetString(datagram);
                    IPAddress addr = from.Address;

                    if (some condition using the 'addr' object)
                         ReceiveString(result);
                }

sorry, typo, it should be:
you can know....
Avatar of Natural_Demon

ASKER

i'll check it out,  i'll let u hear as soon as posible.

kind regards
and how to block a ip?


kind regard
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial