Siemens PLC dynamic connection parameters

Hello, I am trying to create a project that allows to change connection parameters without project's edits. I get parameters from a file stored in my PC. I used file-in to read the file, a switch to read the correct row and a function to get the IP Address from the row. The problem is that I dont know how to set up the connection using these parameters, I have to use TCP/IP protocol. Thanks for any help.