]> Dogcows Code - chaz/yoink/blobdiff - src/Main.cc
better broadcast support
[chaz/yoink] / src / Main.cc
index 835f3d06bc099c6cc3595e6193ab462d9aa308e8..4d88a709e69bb39a71e739a574823e254ff2f0ac 100644 (file)
@@ -221,6 +221,9 @@ void Main::printInfo(int argc, char* argv[])
        }
 
        std::cout << "   Executable: " << argv[0] << std::endl
+#ifdef YOINK_GITHEAD
+                         << "       Commit: "YOINK_GITHEAD << std::endl
+#endif
                          << "      Version: "VERSION << std::endl
                          << "        Built: " << COMPILE_TIME << std::endl
                          << "     Compiler: "COMPILER_STRING << std::endl
@@ -273,8 +276,90 @@ void goodbye()
 }
 
 
+#include <Moof/Socket.hh>
+
 int main(int argc, char* argv[])
 {
+       Mf::ResolverTask task("4950", "compy", SOCK_DGRAM);
+       task.run();
+
+       int i = task.wait();
+       Mf::logWarning << "task ended with code: " << i << std::endl;
+
+       std::vector<Mf::SocketAddress>::const_iterator it;
+       for (it = task.addresses().begin(); it != task.addresses().end(); ++it)
+       {
+               Mf::SocketAddress addr = *it;
+
+               Mf::logInfo << "address: " << addr.name() << ":" << addr.port() 
+                                       << " (" << addr.type() << ")" << std::endl;
+       }
+
+
+       Mf::Packet packet(1000000);
+
+       packet << 5.1234f;
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+       float meh3;
+       packet >> meh3;
+       Mf::logInfo << "float: " << meh3 << std::endl;
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+
+       packet << uint16_t(45);
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+       packet << uint64_t(1234567812345679ULL);
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+       packet << true << false << false << true << false << true << true;
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+       std::vector<short> hi;
+       hi.push_back(34);
+       hi.push_back(-12345);
+       hi.push_back(7734);
+
+       for (int a = 0; a < 15900; a++)
+       {
+               hi.push_back(a);
+       }
+
+       packet << hi;
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+       packet << "hello world";
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+       packet << false << false << false << true << false;
+       Mf::logInfo << "packet size: " << packet.size() << std::endl;
+
+
+       Mf::SocketAddress addr = Mf::SocketAddress::broadcast("4950");
+       //Mf::logInfo << "local addr: " << addr.name() << std::endl;
+
+       //for (it = task.addresses().begin(); it != task.addresses().end(); ++it)
+       //{
+               int bcast = 0;
+
+               //Mf::SocketAddress addr = *it;
+               Mf::Socket sock(addr);
+
+               sock.get(SO_BROADCAST, bcast);
+               Mf::logInfo << "bcast: " << bcast << std::endl;
+
+               sock.set(SO_BROADCAST, 1);
+
+               sock.get(SO_BROADCAST, bcast);
+               Mf::logInfo << "bcast: " << bcast << std::endl;
+
+               sock.write(packet);
+       //}
+
+
+       return 0;
+
+
        if (argc > 1)
        {
                std::string arg(argv[1]);
This page took 0.021494 seconds and 4 git commands to generate.