private static void MapleClientConnect(Socket client) { String ip = ((IPEndPoint)client.RemoteEndPoint).Address.ToString(); if (!AllowConnection(ip)) { client.Shutdown(SocketShutdown.Both); client.Close(); return; } MapleClient Client = new MapleClient(client); try { ushort channelStartPort = ServerConstants.ChannelStartPort; byte channelCount = ServerConstants.Channels; byte channelID = 0; for (byte i = 0; i < ChannelServers.Count; i++) { if (ChannelServers[i].Port == ((IPEndPoint)client.LocalEndPoint).Port) { channelID = (byte)(i); } } if (((IPEndPoint)client.LocalEndPoint).Port == ServerConstants.CashShopPort) { channelID = 0xFF; } Client.Channel = channelID; Client.SendHandshake(); Clients.Add(ip + Functions.Random(), Client); } catch (Exception e) { Client.Disconnect(e.ToString()); } }