Kind of a stupid error I made. All I needed to do was change sock1.connect to sock1.connect txtIP.text, txtPort.text.