%description: Tests UDPSocket method calls: 1. Socket options can be set before the bind() or connect() call. 2. connect() can be called more than once. 3. bind() can be called after connect(). %file: TestApp.cc #include "inet/transportlayer/contract/udp/UDPSocket.h" #include "inet/transportlayer/contract/udp/UDPControlInfo_m.h" using namespace inet; namespace UDPSocket_1 { class TestApp : public cSimpleModule { public: TestApp() : cSimpleModule(65536) {} protected: virtual void activity(); }; Define_Module(TestApp); void TestApp::activity() { UDPSocket s; s.setOutputGate(gate("udpOut")); s.setMulticastLoop(false); s.connect(L3Address("10.0.0.1"), 1000); s.bind(100); s.connect(L3Address("10.0.0.2"), 2000); } } %file: TestApp.ned import inet.applications.contract.IUDPApp; simple TestApp like IUDPApp { gates: input udpIn; output udpOut; } %inifile: omnetpp.ini [General] ned-path = .;../../../../src;../../lib network = SimpleTestNetwork cmdenv-express-mode = false cmdenv-log-prefix = "C:%C: " #omnetpp 5.0 - 5.1 compatibility: eventlog-file = "${resultdir}/${configname}-${runnumber}.elog" output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca" output-vector-file = "${resultdir}/${configname}-${runnumber}.vec" snapshot-file = "${resultdir}/${configname}-${runnumber}.sna" **.client.numUdpApps = 1 **.client.udpApp[0].typename = "TestApp" **.client.udpApp[0].cmdenv-log-level=TRACE %contains: stdout C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)SetMulticastLoop control info: (inet::UDPSetMulticastLoopCommand) C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)CONNECT control info: (inet::UDPConnectCommand) C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)BIND control info: (inet::UDPBindCommand) C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)CONNECT control info: (inet::UDPConnectCommand) %contains-regex: stdout C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket created: sockId=2 appGateIndex=0 localPort=1025 .* C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket connected: sockId=2 appGateIndex=0 localPort=1025 remotePort=1000 remoteAddr=10\.0\.0\.1 multicastLoop=0 .* C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket connected: sockId=2 appGateIndex=0 localPort=100 remotePort=2000 remoteAddr=10\.0\.0\.2 multicastLoop=0 %#-------------------------------------------------------------------------------------------------------------- %not-contains: stdout undisposed object: %not-contains: stdout -- check module destructor %#--------------------------------------------------------------------------------------------------------------