added some other network builtins
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
|
||||
port = 8080;
|
||||
addr = "127.0.0.1";
|
||||
|
||||
fd = net.socket(net.AF_INET, net.SOCK_STREAM, 0);
|
||||
|
||||
if fd < 0:
|
||||
{
|
||||
print('Failed to create socket.\n');
|
||||
return none;
|
||||
}
|
||||
|
||||
sin_addr = {};
|
||||
if net.inet_aton(addr, sin_addr) == 0:
|
||||
{
|
||||
print('Bad address string format.\n');
|
||||
return none;
|
||||
}
|
||||
|
||||
if net.connect(fd, { sin_family: net.AF_INET, sin_port: net.htons(port), sin_addr: sin_addr }) != 0:
|
||||
{
|
||||
print('Failed to connect.\n');
|
||||
return none;
|
||||
}
|
||||
|
||||
print('Connected!\n');
|
||||
Reference in New Issue
Block a user