tags:

views:

128

answers:

2
+1  Q: 

Block Ip Address

How to block one IP Address that is connected to the server, when the server is sending messages. My Sending message option program is shown below.

private void buttonSendMsg_Click(object sender, EventArgs e) {

        try
        {
            Object objData = richTextBoxSendMsg.Text;
            byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());
            for (int i = 0; i < m_clientCount; i++)
            {
                if (m_workerSocket[i] != null)
                {
                    if (m_workerSocket[i].Connected)
                    {

                        m_workerSocket[i].Send(byData);
                    }
                }
            }
        }
+1  A: 

It depends on the server. You can probably do this at the firewall level (and possibly the router level, if you have the right router). A rather simple way to block an IP is to just not accept connections from it wherever the connection would normally show up. In your own applications, this would mean checking the IP before opening it. Most servers allow you to block ips if you wish (e.g. IIS lets you create a blocklist (or an allow list) for each web site/application.

Brian
A: 

As Brian said, this should be a server issue and not an application issue. The server can block things at a much lower layer and is easier to configure.

sybreon