the new version of opencv should come with a new set of examples. a headtracking example should be included somewhere. all relevant information should be in there, all you need to do is adding the socket stuff.
Thanks for the reply, Thomas. As usual, you’re right, there’s a well commented example included with the new opencv had I just looked