First off, this isn't a "help me fix this bug" question...

Preamble:
I have a game program that currently only works when both players are on the same network (no problems there). The program can function as either a "host" or a "client" depending on who starts it first (alerts sent via TCP determine this).

The Task:
What i'm trying to do now is remove all the TCP sending and receiving and replace it all with SQL queries (the SQL & queries aren't the problem). I need to come up with a way for my program to "know" if it is supposed to be the "Host" or the "Client" based on queries sent to the SQL database.. But I can't seem to nail down how to do this.

as of now the database for the game consists of 1 table with 3 rows (player, accesstime, data), but i can add as many more as are needed.

Can anyone offer some ideas?