aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-01-07 07:54:17 +0000
committerdos-reis <gdr@axiomatics.org>2009-01-07 07:54:17 +0000
commita4baedf72d3abfe9f74ee1dade09a454c0ae7c00 (patch)
tree315802f081992e649bc4ae09e8b688f5158d41bf /src/interp
parentcd753a762cfc0b7067806c794f463a3636c3918e (diff)
downloadopen-axiom-a4baedf72d3abfe9f74ee1dade09a454c0ae7c00.tar.gz
* interp/sys-utility.boot (readByteFromFile): Tidy.
(makeByteBuffer): Set fill pointer. (connectToHostAndPort): Define here. (readByteFromStreamSocket): Likewise. (writeByteToStreamSocket): Likewise. * interp/sys-os.boot (doConnectToHostAndPort): Rename from connectot$NetworkClientSocket. (doReadByteFromStreamSocket): Rename from readByteFromStreamSocket. (doWriteByteToStreamSocket): Rename from writeByteToStreamSocket. * algebra/net.spad.pamphlet: Use Maybe Byte. * algebra/data.spad.pamphlet (ByteBuffer): Fix fill pointer thinko.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/sys-os.boot10
-rw-r--r--src/interp/sys-utility.boot29
2 files changed, 28 insertions, 11 deletions
diff --git a/src/interp/sys-os.boot b/src/interp/sys-os.boot
index d41ccfc7..2e9bf84b 100644
--- a/src/interp/sys-os.boot
+++ b/src/interp/sys-os.boot
@@ -1,4 +1,4 @@
--- Copyright (C) 2007-2008 Gabriel Dos Reis.
+-- Copyright (C) 2007-2009 Gabriel Dos Reis.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -125,17 +125,17 @@ import oa__get__host__address: (string, int, writeonly buffer byte) -> int
++ Return -1 on failure, otherwise the file descriptor corresponding
++ to the obtained client socket.
import oa__connect__ip__port__stream: (readonly buffer byte,int,int) -> int
- for connectToHostAndPort
+ for doConnectToHostAndPort
++ Try to read bytes of data from socket.
++ Return -1 for failure; number of read bytes, otherwise.
import oa__socket__read: (int,writeonly buffer byte,int) -> int
for readFromStreamSocket
-++ Try to read a byte socket from a socket.
+++ Try read a byte socket from a socket.
++ Return -1 on failure; byte read, otherwise.
import oa__socket__read__byte: int -> int
- for readByteFromStreamSocket
+ for doReadByteFromStreamSocket
++ Try to write bytes of data to socket.
++ Return -1 on failure; actual bytes written, otherwise.
@@ -145,7 +145,7 @@ import oa__socket__write: (int,readonly buffer byte,int) -> int
++ Try to write a byte to socket.
++ Return -1 on failure; the written byte, otherwise.
import oa__socket__write__byte: (int,int) -> int
- for writeByteToStreamSocket
+ for doWriteByteToStreamSocket
import oa__close__socket: int -> int for closeSocket
diff --git a/src/interp/sys-utility.boot b/src/interp/sys-utility.boot
index 3fcbdf9c..510f5080 100644
--- a/src/interp/sys-utility.boot
+++ b/src/interp/sys-utility.boot
@@ -261,14 +261,11 @@ openBinaryFile(file,mode) ==
KEYWORD::ELEMENT_-TYPE,"%Byte")
++ Attemp to read a byte from input file `ifile'. If not end of
-++ file, return the read byte; otherwise -1.
-readByteFromFile: %Thing -> %Short
+++ file, return the read byte; %nothing.
readByteFromFile ifile ==
- byte := READ_-BYTE(ifile,false) => byte
- -1
+ READ_-BYTE(ifile,false,%nothing)
++ Write byte `b' to output binary file `ofile'.
-writeByteToFile: (%Thing,%Byte) -> %Short
writeByteToFile(ofile,b) ==
WRITE_-BYTE(b,ofile)
@@ -276,11 +273,31 @@ closeFile file ==
CLOSE file
nil
+--% Socket I/O
+
+++ Attempt to establish a client TCP/IP socket connection. The IP numeric
+++ address is specified by the first argument; second argument is the
+++ version of IP used (4 or 6); third argument is the desired port.
+++ Return %nothing on failure, otherwise the file descriptor corresponding
+++ to the obtained client socket.
+connectToHostAndPort(addr,prot,port) ==
+ (socket := doConnectToHostAndPort(addr,prot,port)) < 0 => %nothing
+ socket
+
+++ Attempt to read a byte from the socket `s'. If unsuccessful,
+++ return %nothing.
+readByteFromStreamSocket s ==
+ (byte := doReadByteFromStreamSocket s) < 0 => %nothing
+ COERCE(byte,"%Byte")
+
+writeByteToStreamSocket(s,b) ==
+ (byte := doWriteByteToStreamSocket(s,b)) < 0 => %nothing
+ COERCE(byte,"%Byte")
--%
makeByteBuffer(n,b == 0) ==
MAKE_-ARRAY(n,KEYWORD::ELEMENT_-TYPE,"%Byte",
- KEYWORD::FILL_-POINTER,0, KEYWORD::INITIAL_-ELEMENT,b)
+ KEYWORD::FILL_-POINTER,true, KEYWORD::INITIAL_-ELEMENT,b)
quoteForm t ==
["QUOTE",t]