Пример #1
0
        public static SenderSocket Create(IPAddress ip, SocketSide socketSide, SocketEventProvider eventProvider)
        {
            switch (socketSide)
            {
            default:
            case SocketSide.Server:
                return(new TcpServerSocket(ip, eventProvider));

            case SocketSide.Client:
                return(new TcpClientSocket(ip, eventProvider));
            }
        }
Пример #2
0
        public void Initialize(SystemSocket acceptSocket)
        {
            socket = acceptSocket;
            socketEventProvider = SocketEventProvider.Create(this);

            DoAsync(OnConnected);

            bool willRaiseEvent = socket.ReceiveAsync(socketEventProvider.ReceiveEvent);

            if (willRaiseEvent == false)
            {
                socketEventProvider.ProcessReceive(socketEventProvider.ReceiveEvent);
            }
        }
Пример #3
0
 public TcpServerSocket(IPAddress ip, SocketEventProvider eventProvider)
     : base(ip, SocketType.Stream, SocketSide.Server, eventProvider)
 {
 }
Пример #4
0
 public static SenderSocket Create <T>(IPAddress ip, SocketEventProvider eventProvider)
 {
     return((SenderSocket)Activator.CreateInstance(typeof(T), BindingFlags.Public | BindingFlags.Instance, null, new object[] { ip, eventProvider }, null));
 }
Пример #5
0
 public TcpReceiveSocket(Socket socket, SocketSide socketSide, SocketEventProvider eventProvider) :
     base(((IPEndPoint)socket.RemoteEndPoint).Address, SocketType.Stream, socketSide, eventProvider)
 {
     Sock = socket;
 }
Пример #6
0
 public UdpSocket(IPAddress ip, SocketSide socketSide, SocketEventProvider eventProvider)
     : base(ip, SocketType.Dgram, socketSide, eventProvider)
 {
 }
Пример #7
0
 public TcpClientSocket(IPAddress ip, SocketEventProvider eventProvider)
     : base(ip, SocketType.Stream, SocketSide.Client, eventProvider)
 {
 }