Made socket-var global and implemented join()