public ServerSocket(IPAddress IP, int Port) { RawSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); RawSocket.Bind(new IPEndPoint(IP, Port)); Instance = this; }
static void Main(string[] args) { ServerSocket Socket = new ServerSocket(IPAddress.Any, 25050); Socket.SocketConnectionConnected_Event += new SocketConnectionConnected_Handler(Socket_SocketConnectionConnected_Event); Socket.SocketConnectionDisconnected_Event += new SocketConnectionDisconnected_Handler(Socket_SocketConnectionDisconnected_Event); Socket.SocketConnection_PacketReceived_Event += new SocketConnection_PacketReceived_Handler(Socket_SocketConnection_PacketReceived_Event); Socket.Start(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Listening..."); Console.ReadLine(); }
public SocketConnection(ServerSocket serverSocket, Socket clientSocket) { this.clientSocket = clientSocket; this.serverSocket = serverSocket; this.IP = clientSocket.RemoteEndPoint; this.SqlConnection = new MySqlConnection("Server=blaze-games.com;Uid=root;Pwd=hl1vlAbR9a3Riu;database=blazegameshome5;"); this.SqlConnection.Open(); this.clientSocket.BeginReceive(ClientReceiveBuffer, 0, Packet.MaxLength, SocketFlags.None, new AsyncCallback(ReceivePacket), clientSocket); }