// // The following Middle code was used as input to the C++ // Middleware Writer. // // MsgManager // @msg_id_1 (std::vector, std::string) // @msg_id_2 (std::set) // } // #include #include #include #include #include #include #include #include #include using namespace cmw; int main() try { int sd = getSocket(SOCK_DGRAM); SendBuffer buffer; buffer.sock_ = sd; ::std::cout << "Enter the ID of the message you want to send: 1 or 2." << ::std::endl; int msgID; ::std::cin >> msgID; if (msgID < 1 || msgID > 2) { return 0; } MsgManager msgManager(20000); if (1 == msgID) { ::std::vector ivec; for (int j = 40; j < 100; j += 3) { ivec.push_back(j); } ::std::string s = "Proverbs 24:27"; msgManager.Marshal(buffer, ivec, s); } else { ::std::set iset; for (int j = 40; j < 100; j += 3) { iset.insert(j*2); } msgManager.Marshal(buffer, iset); } sockaddr_in si_other; memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(12345); if (inet_aton("127.0.0.1", &si_other.sin_addr)==0) { ::std::cout << "inet_aton() failed\n"; return 0; } buffer.Flush((sockaddr*) &si_other, sizeof(si_other)); return 1; } catch (std::exception const& ex) { ::std::cout << "failure: " << ex.what() << ::std::endl; }