Created
May 3, 2016 14:04
-
-
Save saghul/2ce6dc09d6d0fb54ada095ac091a912b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net'); | |
var r = net.getaddrinfo('localhost', '', {family: net.AF_INET, | |
type: net.SOCK_STREAM}) | |
var ip = r[0].address.host; | |
var sock = new net.Socket(net.AF_INET, net.SOCK_STREAM); | |
sock.connect({host: ip, port: 1234}); | |
sock.send('hello!'); | |
var data = sock.recv(); | |
print('Received data: ' + data); | |
sock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment