示例#1
0
        public Socket(System.Net.IPAddress address, int port)
        {
            this.OnConnect += ()    => { };

            this.OnData    += data  => { };

            this.OnError   += error => { };

            this.OnEnd     += ()    => { };

            this.sending    = false;

            this.endpoint   = new System.Net.IPEndPoint(address, port);

            this.socket     = Reactor.Udp.Socket.Create();

            this.socket.Bind(System.Net.IPAddress.Any, 0);

            this.socket.OnMessage += (remote, data) => {

                if (remote.ToString() == this.endpoint.ToString()) {

                    this.Receive(data);
                }
            };

            var syn = new Syn(Random.Get());

            this.socket.Send(this.endpoint, syn.Serialize());
        }
示例#2
0
        internal void ReceiveSyn(Syn          syn)
        {
            var synack = new SynAck(Random.Get(), syn.SequenceNumber + 1);

            this.socket.Send(this.endpoint, synack.Serialize());
        }