Added ability to do getaddrinfo() and connect() asynchronously

Spawns a thread whenever it attempts to connect to a network so the rest
of the client does not have to hang on the connection attempt
In addition, print_to_buffer() has been modified so that instead of
immediately trying to write to a buffer and refresh it, it waits until
the main loop has finished processing events, then reads from a message
queue and refreshes the output. This had to be done so that
print_to_buffer() could be called from any thread without causing race
conditions.