I want to establish a TCP connection from my application in Omnet++ to an external server.
This is my sample code
inet::TCPSocket mysocket;
mysocket.connect(inet::L3Address("192.168.12.226"),10000);
EV<< "Socket connection" <<endl;
cPacket * msg = new cPacket("solve");
msg->setByteLength(1024); // 1K
mysocket.send(msg);
mysocket.close();
This code compile, but when I run my application this error appears
SetOutputGate() must be invoked before socket can be used
The example code in the TCPSocket.h is very similar.
I don't understand this error.
Any suggestions?
Thanks.
You should add:
mysocket.setOutputGate(gate("tcpOut"));