moved socket creation to synchronized method

@gsoltis this should fix the race condition that occurred when closing the socket while connecting
I like to keep public methods synchronized and private methods unsynchronized in general. Personal taste. Should I change it?