]> Dogcows Code - chaz/yoink/blobdiff - src/Main.cc
better socket sending/receiving
[chaz/yoink] / src / Main.cc
index fc84ceb38fcc3171743faec7eeca3a6c750f7f78..051b22c5a4998e71a5ecb61468227f4fafbe3cec 100644 (file)
@@ -40,8 +40,6 @@ Main::Main(Mf::Settings& settings, Mf::Video& video) :
        mNewContextDispatch = dispatch.addTarget("video.newcontext",
                                                                                         boost::bind(&Main::setupGL));
        setupGL();
-
-       addChild(TitleLayer::alloc());
 }
 
 
@@ -49,9 +47,10 @@ void Main::update(Mf::Scalar t, Mf::Scalar dt)
 {
        if (children().size() == 0)
        {
-               Mf::logWarning("main view has no children");
-               stop();
-               return;
+               //Mf::logWarning("main view has no children");
+               //stop();
+               //return;
+               addChild(TitleLayer::alloc());
        }
 
        Mf::View::update(t, dt);
@@ -222,11 +221,18 @@ 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
                          << "       Assets: " << assets << std::endl
                          << "Build options: "
+#ifndef HAVE_CLOCK_GETTIME
+                         << "-"
+#endif
+                         << "clock_gettime "
 #ifdef NDEBUG
                          << "-"
 #endif
@@ -270,8 +276,66 @@ 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;
+       }
+
+
+       std::vector<uint8_t> hi;
+       for (int a = 0; a < 4000; a++)
+       {
+               hi.push_back(a);
+       }
+
+       Mf::logInfo << "array size: " << hi.size() << std::endl;
+       Mf::Packet packet;
+       packet << hi;
+
+       Mf::SocketAddress addr("4950", "155.98.111.159", SOCK_DGRAM);
+       //Mf::SocketAddress addr = Mf::SocketAddress::broadcast("4950");
+       //Mf::SocketAddress addr("4950", "155.98.109.255", SOCK_DGRAM);
+       //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.connect();
+
+               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;
+
+               Mf::logInfo << "sending packet of size: " << packet.size() << std::endl;
+               //sock.write(packet);
+               sock.write(&bcast, sizeof(bcast));
+       //}
+
+
+       return 0;
+
+
        if (argc > 1)
        {
                std::string arg(argv[1]);
This page took 0.019557 seconds and 4 git commands to generate.