Example TCP Rule Function to Start a Local TCP Server
Here is a sample rule function to start a local TCP server:
Copy
void rulefunction RuleFunctions.InitTCPServers {
attribute {
validity = ACTION;
}
scope {
}
body {
System.debugOut( "Initializing TCP servers" ) ;
try {
TCP.createLocalServer("MyTCPServer", "localhost", System.getGlobalVariableAsInt("NSN/SocketAdaptor/Port", 8055));
TCP.registerSessionListener("MyTCPServer", "/RuleFunctions/RawCDRCallback");
TCP.startLocalServer("MyTCPServer");
} catch (Exception ex) {
System.debugOut("Exception occurred while initializing TCP server: " +
ex@message);
}
System.debugOut("TCP server initialization done");
}
}