Hello,
I am trying to connect to a server using TCP through a VPN.
I am using the following code (not with XX.X.X.X, of course):
// We create a new node to keep track of which connection to use later on. Something else, like // a Global Variable, could be used for the same purpose. treenode connection = Model.find("/Tools/connection"); if(!connection){ connection = model().find("Tools").subnodes[1].copy(); connection.name = "connection"; connection.value = 1; while(connection.subnodes.length > 0){ connection.subnodes[1].destroy(); } } string hostname = "XX.X.X.X"; int portnum = 25025; int client = 0; // Initialize the socket before trying to create a connection. socketinit() return TRUE // if the initialization is successful and reutrns FALSE if it is not successful. if(socketinit()) { client = clientcreate(); // Start the process to use Windows sockets as a client. } // clientcreate() returns TRUE if the process could start properly and FALSE if it couldn't. if( client ) { // Make the connection to this machine using given hostname and port number. if(clientconnect(client,hostname,portnum)){ // Set the client node created earlier with the connectin value. connection.value = client; /* CODE*/ } else{ msg("Client Error", "Failed to connect to server."); // The connection could not be made. if(!clientclose(client)) msg("Socket Error", "Failed to close client socket."); // The socket did not close properly. return 0; // Return a 0 to indicate an issue. } } else{ int user = msg("Socket Error", "Failed to create client socket."); // The process for socket connection could not start. if(user != 1){ stop(); } return client; // Return value in client variable (0) to indicate an error. }
The clientconnect function always returns False.
I have been testing the connection with a Python file and it works perfectly. Therefore, it seems that the problem is related to Flexsim.
Is it possible that Flexsim does not connect to the VPN? Could it be that the VPN rejects the connection with Flexsim?
I appreciate any help or suggestions you can provide.