int main(int argc, char** argv) { UdpSocket client; client.bind(8002); const char* message = "ahoj\n"; //client.write("224.3.29.71", 8001, message); multicast /*int broadcastEnable=1; int ret = setsockopt(client.get_handle(), SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable)); client.write("255.255.255.255", 8001, message); // broadcast */ printf("Sending to server: %s", message); client.write("localhost", 8001, message); sockaddr_in from_addr; unsigned int from_len; char buf[1024]; int size = client.readline(buf, sizeof(buf), (sockaddr*) &from_addr); buf[size] = '\0'; printf("Received from server: %s", buf); client.close(); return 0; }
int main() { UdpSocket s; Host h("localhost", 2001); if (s.sendString("hello world", h) == AbstractSocket::Done) cout << "Done" << endl; else perror("Error"); if (s.sendInt32(666, h) == AbstractSocket::Done) cout << "Done" << endl; else perror("Error"); if (s.sendInt8('&', h) == AbstractSocket::Done) cout << "Done" << endl; else perror("Error"); size_t ts = 21; if (s.sendCharArray("this is a char array", ts, h) == AbstractSocket::Done) cout << "Done" << endl; else perror("Error"); Frame f; f << "This is a frame " << 666 << '\n'; if (s.sendFrame(f, h) != AbstractSocket::Done) perror("error"); else cout << "done" << endl; s.close(); }
int main(int argc, char* argv[]) { /* Concept: 1) UdpSocket listens for input data. 2) Data is passed to H264Decoder which than parses the NALU files and passes everything to ffmpeg. The decoded data is than passed to the SdlViewer instance; 3) The SdlViewer uses SDL with OpenGL acceleration to show the received frames. */ for(int i = 1; i < argc; ++i) { std::string value(argv[i]); if (value == "--fullscreen") { fullscreen = true; }else if(value == "--oculus"){ viewer = new OculusViewer(DEFAULT_WIDTH, DEFAULT_HEIGHT); }else if (value == "--help" || value == "-h") { cout << "--help no idea what exactly this parameter does" << endl << "--fullscreen open fullscreen opengl context instead of vga window" << endl << "--oculus adjust screen window for Oculus Rift DK2" << endl; return 0; } } if(viewer == nullptr){ viewer = new SdlViewer(DEFAULT_WIDTH, DEFAULT_HEIGHT); } input.initClient(cfg.getValueOfKey<string>("TARGET_IP").c_str(), TARGET_PORT); input.setInitCallback(&init); input.send(PROTOCOL_TYPE_INIT, nullptr, 0); viewer->setInputCallback(&inputCallback); viewer->setPositionCallback(&positionCallback); viewer->show(fullscreen); input.send(PROTOCOL_TYPE_CLOSE, nullptr, 0); input.close(); return 0; }