version 1.29, 2009/12/09 09:43:33
|
version 1.30, 2009/12/09 20:42:52
|
Line 91 sockaddr-tmp sockaddr_in %size dup allot
|
Line 91 sockaddr-tmp sockaddr_in %size dup allot
|
11 Constant EWOULDBLOCK |
11 Constant EWOULDBLOCK |
$100 Constant MSG_WAITALL |
$100 Constant MSG_WAITALL |
$802 Constant O_NONBLOCK|O_RDWR |
$802 Constant O_NONBLOCK|O_RDWR |
2000 Value SOCKET-TIMEOUT |
2variable socket-timeout-d 2000. socket-timeout-d 2! |
|
|
: new-socket ( -- socket ) |
: new-socket ( -- socket ) |
PF_INET SOCK_STREAM IPPROTO_TCP socket |
PF_INET SOCK_STREAM IPPROTO_TCP socket |
Line 122 $802 Constant O_NONBLOCK|O_RDWR
|
Line 122 $802 Constant O_NONBLOCK|O_RDWR
|
|
|
' open-socket Alias open-service |
' open-socket Alias open-service |
|
|
: ms@ utime 1000 ud/mod drop nip ; ( -- u ) |
|
|
|
: $put ( c-addr1 u1 c-addr2 -- ) swap cmove ; |
: $put ( c-addr1 u1 c-addr2 -- ) swap cmove ; |
|
|
: $+ ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 ) |
: $+ ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 ) |
Line 163 Create crlf 2 c, 13 c, 10 c,
|
Line 161 Create crlf 2 c, 13 c, 10 c,
|
hostname$ 1+ 255 0 scan nip 255 swap - hostname$ c! |
hostname$ 1+ 255 0 scan nip 255 swap - hostname$ c! |
THEN |
THEN |
hostname$ count ; |
hostname$ count ; |
: set-socket-timeout ( u -- ) 200 + to socket-timeout ; |
: set-socket-timeout ( u -- ) 200 + s>d socket-timeout-d 2! ; |
: get-socket-timeout ( -- u ) socket-timeout 200 - ; |
: get-socket-timeout ( -- u ) socket-timeout-d 2@ drop 200 - ; |
: write-socket ( c-addr size socket -- ) fileno -rot 0 send 0< throw ; |
: write-socket ( c-addr size socket -- ) fileno -rot 0 send 0< throw ; |
: close-socket ( socket -- ) fileno closesocket drop ; |
: close-socket ( socket -- ) fileno closesocket drop ; |
|
|
Line 178 Create crlf 2 c, 13 c, 10 c,
|
Line 176 Create crlf 2 c, 13 c, 10 c,
|
r> true blocking-mode ; |
r> true blocking-mode ; |
|
|
: read-socket ( socket c-addr maxlen -- c-addr u ) |
: read-socket ( socket c-addr maxlen -- c-addr u ) |
ms@ socket-timeout + { socket c-addr maxlen tmax -- c-addr size } |
utime socket-timeout-d 2@ d+ { socket c-addr maxlen d: tmax -- c-addr size } |
BEGIN |
BEGIN |
socket c-addr maxlen (rs) dup 0= |
socket c-addr maxlen (rs) dup 0= |
ms@ tmax u< and |
utime tmax d< and |
WHILE |
WHILE |
2drop |
2drop |
REPEAT ; |
REPEAT ; |