Ehm, you shouldn't have c&p'd the code, it was just a skeleton, you need to change stuff in it. .
I never used this version you are using so look for something like this from a proxy i was making a while ago:
Code:
private void OnClientConnect(IAsyncResult Res)
{
string[] IPS = File.ReadAllText(Application.StartupPath + @"\BannedIPs.txt").Split('\r', '\n'); // here i read the ips that i want to block
SocketPacket sender = null;
try
{
sender = new SocketPacket(this.ProxySocket.EndAccept(Res)) { Connected = true };
foreach (string IP in IPS)
{
if (IP == sender.RemoteIP) // I created a property for the ip it is the same as Socket.RemoteEndPoint.ToString().Split(':')[0]
{
if (this.OnClientBlocked != null)
{
this.OnClientBlocked.Invoke(sender, null);
}
sender.Connected = false;
sender.cont = false;
sender.ClientSocket.Disconnect(true);
}
else
{
sender.cont = true;
}
}
if (sender.cont == true)
{
ClientPool.Add(sender.UniqueID, sender);
if (this.OnClientConnected != null)
this.OnClientConnected.Invoke(sender, null);
if (sender.Connected)
{
sender.ClientSocket.BeginReceive(sender.dataBuffer, 0, sender.dataBuffer.Length, SocketFlags.None
, new AsyncCallback(this.OnDataRecieve), sender);
}
}
}
catch (Exception)
{
if (this.Enabled)
{
sender.cont = false;
sender.Connected = false;
if (this.OnClientDisconnect != null)
{
this.OnClientDisconnect.Invoke(sender, null);
}
}
}
finally
{
if (this.Enabled)
ProxySocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
}