diff options
| author | Drahflow <drahflow@gmx.de> | 2013-09-03 10:50:37 +0200 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2013-09-03 10:50:37 +0200 |
| commit | 17245cb03fb02ae9c6b0409c1e6bdb538322a498 (patch) | |
| tree | 25e8e47f26102b8ae3b9bd139bf878daae0c5386 | |
| parent | 7560990d9c614e150ded685004a6a0e2c6eb3034 (diff) | |
TCP/IP listening support
net .tcp ":" via
2000 :listen :accept "+" via
sys .out "->" via
{ 65536 +read _ len } { ->writeall } loop
"Connection terminated" dump
| -rw-r--r-- | elymas/lib/net/tcp.ey | 23 | ||||
| -rw-r--r-- | elymas/lib/sys/linux.ey | 12 |
2 files changed, 32 insertions, 3 deletions
diff --git a/elymas/lib/net/tcp.ey b/elymas/lib/net/tcp.ey index dc77515..e7ef31e 100644 --- a/elymas/lib/net/tcp.ey +++ b/elymas/lib/net/tcp.ey @@ -32,6 +32,29 @@ { connectFd sys .fdToFile } /connect deffd + + # 0 -> port + # 0 <- listening socket fd + { # ==port + 0 <=un32 -01 sockaddrIpv4 + +AFINET +SOCKSTREAM +IPPROTOTCP +socket _ ==s # TODO: error handling + -01 +bind -- # TODO: error handling + s 256 +listen -- # TODO: error handling + s + } _ /listenFd deffd + /listen deffd + + # 0 -> listening socket fd + # 0 <- newly accepted connection fd + { # ==fd + +accept # TODO: error handling + } /acceptFd deffd + + # 0 -> listening socket fd + # 0 <- newly accepted connection as file + { # ==fd + acceptFd sys .fdToFile + } /accept deffd > /tcp net .defv # vim: syn=elymas diff --git a/elymas/lib/sys/linux.ey b/elymas/lib/sys/linux.ey index 8f3abfb..0c00fc9 100644 --- a/elymas/lib/sys/linux.ey +++ b/elymas/lib/sys/linux.ey @@ -3,7 +3,7 @@ # argument order tends to follow kernel API < - # 43 ==:ACCEPT + 43 ==:ACCEPT # 288 ==:ACCEPT64 # 21 ==:ACCESS # 163 ==:ACCT @@ -12,7 +12,7 @@ # 183 ==:AFSSYSCALL # 37 ==:ALARM # 158 ==:ARCHPRCTL - # 49 ==:BIND + 49 ==:BIND # 12 ==:BRK # 125 ==:CAPGET # 126 ==:CAPSET @@ -121,7 +121,7 @@ # 192 ==:LGETXATTR # 86 ==:LINK # 265 ==:LINKAT - # 50 ==:LISTEN + 50 ==:LISTEN # 194 ==:LISTXATTR # 195 ==:LLISTXATTR # 212 ==:LOOKUPDCOOKIE @@ -321,6 +321,10 @@ deffd }' /defStdSyscall deff + { 0 0 0 0 0 ACCEPT } /accept defStdSyscall + + { _ len 0 0 0 BIND } /bind defStdSyscall + { 0 0 0 0 0 CLOSE } /close defStdSyscall { _ len 0 0 0 CONNECT } /connect defStdSyscall @@ -385,6 +389,8 @@ } /wait deffd > /epoll defvd + { 0 0 0 0 LISTEN } /listen defStdSyscall + 1 ==:AFUNIX 1 ==:AFLOCAL 2 ==:AFINET |
