aboutsummaryrefslogtreecommitdiff
path: root/src/interp/sys-utility.boot
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/sys-utility.boot
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/sys-utility.boot')
-rw-r--r--src/interp/sys-utility.boot29
1 files changed, 23 insertions, 6 deletions
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]