added send and recv builtins
This commit is contained in:
+18
-1
@@ -22,6 +22,8 @@ if net.listen(fd, backlog) != 0:
|
||||
return none;
|
||||
}
|
||||
|
||||
buffer = newBuffer(16);
|
||||
|
||||
while true:
|
||||
{
|
||||
client_addr = {};
|
||||
@@ -34,5 +36,20 @@ while true:
|
||||
print('client_fd = ', client_fd, '\n');
|
||||
print('client_addr = {', client_addr, '}\n');
|
||||
|
||||
# ..continue..
|
||||
do
|
||||
{
|
||||
n = net.recv(client_fd, buffer, 0);
|
||||
|
||||
if n < 0:
|
||||
print('Warning! Failed to read from socket!\n');
|
||||
else if n == 0:
|
||||
{
|
||||
# Client disconnected.
|
||||
}
|
||||
else
|
||||
{
|
||||
print('Received ', n, ' bytes: ', buffer, '\n');
|
||||
}
|
||||
}
|
||||
while n > 0;
|
||||
}
|
||||
Reference in New Issue
Block a user