In this article
https://smartfoxserver.com/blog/best-of ... -games-p2/we explain how to pass init parameters to the Unity headless server. This is useful for setting up the game etc.
Typically you shouldn't need to continuosly send data between SFS2X and the headless Unity while the game is running. The Unity engine is supposed to handle the game logic in its entirety.
Of course you can still send events to SFS2X if something "interesting happens", such as the game is finished and you want to notify SFS2X for some reason. You can use HTTP and invoke a custom servlet, for example.
Otherwise if you need continuous communication you will need to establish a local connection via socket to SFS2X, though I would probably try to design the game without it, if possible.
To give you an example, imagine a real-time racing game for 8 players per "Room".
You want all the User and Room Management, Buddy lists and matchmaking handled by SFS2X. When 8 players are matched together you can create a new Room and assign a new Unity headless server to it.
The Unity headless is sent a bunch of parameters to setup the game and from there each player will connect to the Unity server for the racing game. At this point you've two connections from each player, one for the SFS2X services and one for the Unity server, to handle the game.
The race beings and all of the game related messaging is happening between the client and the Unity server. If anyone disconnects from Unity you will handle the logic in there. When the game ends you will probably want to save the scores, the placement of each player etc. Maybe in a database. Here you can call a custom SFS2X servlet from Unity and perform some database work from there.
Or you may just decide that you prefer to talk to the database directly from Unity and skip the middle-man, which is also not a bad idea.
Hope it helps