public void startTimer() { timer = new QTimer(this); // only fire the timer once timer.setSingleShot(true); timer.timeout.connect(this, "reSend()"); timer.start(timeout); // go after 1 second }
public Net(ushort initPort, IList <string> initPeers) { // For each peer name in the command-line arguments, // create a Peer object to represent and track that peer. foreach (string peerName in initPeers) { peers.Add(new Peer(this, peerName)); //peerList.add(peerName); } //Console.WriteLine(peers.Count); for (int i = 0; i < peers.Count; i++) { peerList.add(peers[i].betterName); } // Bind our UDP socket to the specified (or default) port // allowing us to send and receive network datagrams. if (initPort == 0) { initPort = NetConf.defaultPort; } // Like println in Java Console.WriteLine("Binding to port " + initPort); sock.bind(new QHostAddress(QHostAddress.SpecialAddress.Any), initPort); sock.readyRead.connect(this, "receive()"); // Save some identifying information for printfs and such. myPort = initPort; myName = QHostInfo.localHostName() + ":" + myPort; // Create a timer to trigger repeating "pings" // we send out to to all our peers. QTimer timer = new QTimer(this); timer.timeout.connect(this, "pingAllPeers()"); timer.start(1000); // ping once every second }