public Sender(IPv4 localAddress, ushort localPort, IPv4 remoteAddress, ushort remotePort, int maxSendPackets) { Core c = Core.Instance(); TcpModule m = c.GetProtocolByName("TCP") as TcpModule; this.session = (TcpSession)m.CreateSession(); this.session.Connect(localAddress, localPort, remoteAddress, remotePort); this.maxSendPackets = maxSendPackets; this.sentPackets = 0; this.worker = new Thread(new ThreadStart(WorkLoop)); this.worker.Start(); }
public Receiver(IPv4 localAddress, ushort localPort, int maxReceivePackets) { Core c = Core.Instance(); TcpModule m = c.GetProtocolByName("TCP") as TcpModule; this.maxReceivePackets = maxReceivePackets; this.receivedPackets = 0; this.listener = (TcpSession)m.CreateSession(); if (this.listener.Listen(localAddress, localPort) == false) { Console.WriteLine("TcpSession.Listen() failed."); } this.worker = new Thread(new ThreadStart(WorkLoop)); this.worker.Start(); }