Re-use some low level socket code in inf-native-socket.[hc]