How do I do that. I know that I need to thread the application but I've never written a program this complex

. 1500 lines of code, all in a single cpp file isn't too easy to mess with

.
I have very little experience with network programming and the only sort of network programming I've done is web management, where I wrote applications in PHP.
I feel quite shot in the dark and if anyone knows something about bare C++ network programming with threads, I'd love it if you can help me out
I don't know how to have 2 programs communicate with each other, but using file IO gives me a few worries. What about the possibility of the file getting corrupted by one program writing it and the other reading it at the same time? I need bidirectional communication so that means the likely-ness of both writing is great. I don't want the program to wait for the socket server because my framerate should NEVER dip under 15fps, meaning I need to juice the processor!