Can device be connected to iphone via TCP socket

Hi, I would like to know if Apple permit to connect an electronic device to an iPhone Hotspot and open a TCP socket connection between them (between the electronic device and an iOS app on the iPhone). The iPhone (app) would be the Server and the device would be the client. This will allow data transfer between them, and the iPhone (app) will be able to be in contact with an external server.

If it is permitted, I've read on different forums that the iPhone IP is not static and that it could make a problem to a TCP connection, is that correct? If it is, do you know a solution to that problem?

Thank you in advance!