g++ is now compiling with c99. Moved everything related to UDP connection and transmission to its own fucntion. Main is now cleaner.