كونكر عرب

كونكر عرب (https://conquer-arab.com/index.php)
-   مشكلات السيرفيرات كونكر الشخصيه (https://conquer-arab.com/forumdisplay.php?f=12)
-   -   لو سمحتوا عاوز كونكت سوكت علشان اللي عندي مبوظ السورس (https://conquer-arab.com/showthread.php?t=2843)

سمير 2019-11-08 10:08 PM

لو سمحتوا عاوز كونكت سوكت علشان اللي عندي مبوظ السورس
 
لو سمحتوا عاوز كونكت سوكت علشان اللي عندي مبوظ السورس

zezonever 2019-11-08 11:57 PM

رد: لو سمحتوا عاوز كونكت سوكت علشان اللي عندي مبوظ السورس
 
ده ملف ServerSocket.cs اتفضل بتاع سرفري

كود PHP:

namespace BlackBlock.Network.Sockets
{
    
using System;
    
using System.Collections.Concurrent;
    
using System.Net;
    
using System.Net.Sockets;
    
using System.Runtime.InteropServices;
    
using System.Threading;
    
using BlackBlock;

    public 
delegate void NetworkClientConnection(ClientWrapper client);
    public 
delegate void NetworkClientReceive(Byte[] buffer, Int32 length, ClientWrapper client);

    public class 
ServerSocket
    
{
        public 
Socket Socket { get; private set; }
        public 
IPEndPoint LocalEndPoint { get; private set; }
        public 
String Name { get; private set; }

        public 
NetworkClientConnection OnConnect;
        public 
NetworkClientReceive OnReceive;
        public 
NetworkClientConnection OnDisconnect;
        public 
BruteForceAttackProtection AttackProtector;

        public 
Int32 ClientBufferSize;

        public 
ServerSocket(String name, UInt32 maximum, UInt32 banTime)
        {
            
Name = name;
            
AttackProtector = new BruteForceAttackProtection(maximum, banTime);
        }

        public 
void Prepare(int port, IPProtectionLevel protectionLevel)
        {
            
LocalEndPoint = new IPEndPoint(IPAddress.Any, port);
            
Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            
Socket.Bind(LocalEndPoint);
            
Socket.SetIPProtectionLevel(protectionLevel);
            
Socket.NoDelay = true;
            
Socket.Listen((int)SocketOptionName.MaxConnections);
        }

        public 
void BeginAccept()
        {
            
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, false);
            
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
            
Socket.BeginAccept(Accept, null);
        }

        private 
void Accept(IAsyncResult result)
        {
            
Socket clientSocket;

            try
            {
                
clientSocket = Socket.EndAccept(result);
            }
            catch (
SocketException)
            {
                
BeginAccept();
                return;
            }

            if (
AttackProtector.Authenticate(clientSocket))
            {
                
clientSocket.ReceiveBufferSize = ClientBufferSize;
                var 
client = new ClientWrapper(this, clientSocket, ClientBufferSize);
                
InvokeOnConnect(client);
                
client.BeginReceive();
            }
            else
                
clientSocket.Disconnect(false);
            
BeginAccept();
        }

        public 
void InvokeOnConnect(ClientWrapper client)
        {
            if (
OnConnect != null) OnConnect(client);
        }

        public 
void InvokeOnReceive(Byte[] buffer, Int32 length, ClientWrapper client)
        {
            if (
OnReceive != null) OnReceive(buffer, length, client);
        }

        public 
void InvokeOnDisconnect(ClientWrapper client)
        {
            if (!
client.IsAlive) return;

            if (
OnDisconnect != null) OnDisconnect(client);
        }
    }
} 



الساعة الآن 06:24 AM

مرحبا بكم في منتدي اكواد لتطوير الالعاب
new notificatio by 9adq_ala7sas