added some other network builtins

This commit is contained in:
cozis
2021-12-04 15:22:10 +01:00
parent 4cf95336e8
commit 57c0d7c910
7 changed files with 766 additions and 228 deletions
+24 -5
View File
@@ -1,9 +1,28 @@
print('test 0\n');
addr = "216.58.208.142";
port = 80;
print('SOCK_STREAM = ', network.SOCK_STREAM, ';\n');
fd = net.socket(net.AF_INET, net.SOCK_STREAM, 0);
print('test 1\n');
if fd < 0:
{
print('Failed to create socket\n');
return none;
}
fd = network.socket(network.AF_INET, network.SOCK_STREAM, 0);
print(fd);
in_addr = {};
if net.inet_aton(addr, in_addr) == 0:
{
print('Bad address string format\n');
return none;
}
r = net.connect(fd, {sin_family: net.AF_INET, sin_port: net.htons(port), sin_addr: in_addr});
if r < 0:
{
print('Failed to connect\n');
return none;
}
print('Connected!\n');