After some trial and error I am now using winsock.