Where to place "Per Frame" Code

Hi:
Im currently doing a project which requres a network connection to the remote server.
Then I wrote a socket in another thread and in the main thread I need to call the query function every frame.
Where is the best place to do this sort of querying work?

Thanks in Advance.