From 3d4576ed847bfd84b3befaf7c5ae7ee62905ab2a Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 24 Oct 2008 06:40:59 +0000 Subject: Add basic support for stream client socket. * lib/sockio-c.c (oa_inet_pton): Define. (oa_get_host_address): Likewise. * algebra/net.spad.pamphlet (IP4Address): New. (NetworkClientSocket): Likewise. (InetClientStreamSocket): Likewise. * algebra/data.spad.pamphlet (DataArray): Rename from DataBuffer. (ByteBuffer): Rename from ByteArray. Reimplement. * algebra/exposed.lsp.pamphlet: Expose IP4Address, InetClientStreamSocket, NetworkClientSocket. --- src/interp/define.boot | 8 ++++---- src/interp/sys-os.boot | 32 +++++++++++++++++++++++++++----- src/interp/sys-utility.boot | 6 ++++++ src/interp/wi1.boot | 4 ++-- src/interp/wi2.boot | 4 ++-- 5 files changed, 41 insertions(+), 13 deletions(-) (limited to 'src/interp') diff --git a/src/interp/define.boot b/src/interp/define.boot index a0ab70db..aec9d7ef 100644 --- a/src/interp/define.boot +++ b/src/interp/define.boot @@ -410,11 +410,11 @@ compDefineCategory2(form,signature,specialCases,body,m,e, pairlis:= [[a,:v] for a in argl for v in $FormalMapVariableList] parSignature:= SUBLIS(pairlis,signature') parForm:= SUBLIS(pairlis,form) - rwriteLispForm('"compilerInfo", + lisplibWrite('"compilerInfo", removeZeroOne ['SETQ,'$CategoryFrame, ['put,['QUOTE,op'],' (QUOTE isCategory),true,['addModemap,MKQ op',MKQ parForm, - MKQ parSignature,true,MKQ fun,'$CategoryFrame]]]) + MKQ parSignature,true,MKQ fun,'$CategoryFrame]]],$libFile) --Equivalent to the following two lines, we hope if null sargl then evalAndRwriteLispForm('NILADIC, @@ -643,14 +643,14 @@ compDefineFunctor1(df is ['DEF,form,signature,$functorSpecialCases,body], $lisplibSlot1 := $NRTslot1Info --NIL or set by $NRTmakeSlot1 $lisplibOperationAlist:= operationAlist $lisplibMissingFunctions:= $CheckVectorList - rwriteLispForm('"compilerInfo", + lisplibWrite('"compilerInfo", removeZeroOne ['SETQ,'$CategoryFrame, ['put,['QUOTE,op'],' (QUOTE isFunctor), ['QUOTE,operationAlist],['addModemap,['QUOTE,op'],[' QUOTE,parForm],['QUOTE,parSignature],true,['QUOTE,op'], ['put,['QUOTE,op' ],'(QUOTE mode), - ['QUOTE,['Mapping,:parSignature]],'$CategoryFrame]]]]) + ['QUOTE,['Mapping,:parSignature]],'$CategoryFrame]]]],$libFile) if null argl then evalAndRwriteLispForm('NILADIC, ['MAKEPROP, ['QUOTE,op'], ['QUOTE,'NILADIC], true]) diff --git a/src/interp/sys-os.boot b/src/interp/sys-os.boot index 8478299e..bfa70eba 100644 --- a/src/interp/sys-os.boot +++ b/src/interp/sys-os.boot @@ -103,12 +103,34 @@ import oa__open__local__client__stream__socket: string -> int --% INET socket stream support -import oa__open__ip4__client__stream__socket: (string,int) -> int - for openIP4ClientStreamSocket - -import oa__socket__read: (int,string,int) -> int for readFromStreamSocket +++ Convert an IP address (4 or 6) to numeric form. The result of +++ the conversion is stored in the last argument. The return value +++ is interpreted as follows: +++ -1: failure +++ 0: success +++ Note that at the moment, only IP4 is supported. +import oa__inet__pton: (string, int, writeonly buffer byte) -> int + for presentationToNumeric + +++ Try to resolve a network hostname to its IP address. On success, +++ return 0, otherwise -1. The IP address is written into the +++ third argument. +import oa__get__host__address: (string, int, writeonly buffer byte) -> int + for hostnameToNumeric + +++ Try 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 -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 + +import oa__socket__read: (int,writeonly buffer byte,int) -> int + for readFromStreamSocket -import oa__socket__write: (int,string,int) -> int for writeToStreamSocket +import oa__socket__write: (int,readonly buffer byte,int) -> int + for writeToStreamSocket import oa__close__socket: int -> int for closeSocket diff --git a/src/interp/sys-utility.boot b/src/interp/sys-utility.boot index 3c820e9f..977859a3 100644 --- a/src/interp/sys-utility.boot +++ b/src/interp/sys-utility.boot @@ -265,3 +265,9 @@ writeByteToFile(ofile,b) == closeFile file == CLOSE file nil + + +--% +makeByteBuffer(n,b == 0) == + MAKE_-ARRAY(n,KEYWORD::ELEMENT_-TYPE,"%Byte", + KEYWORD::FILL_-POINTER,0, KEYWORD::INITIAL_-ELEMENT,b) diff --git a/src/interp/wi1.boot b/src/interp/wi1.boot index abc58773..0293178c 100644 --- a/src/interp/wi1.boot +++ b/src/interp/wi1.boot @@ -1228,11 +1228,11 @@ compDefineCategory2(form,signature,specialCases,body,m,e, pairlis:= [[a,:v] for a in argl for v in $FormalMapVariableList] parSignature:= SUBLIS(pairlis,signature') parForm:= SUBLIS(pairlis,form) ----- evalAndRwriteLispForm('"compilerInfo", +---- lisplibWrite('"compilerInfo", ---- ['SETQ,'$CategoryFrame, ---- ['put,['QUOTE,op'],' ---- (QUOTE isCategory),true,['addModemap,MKQ op',MKQ parForm, ----- MKQ parSignature,true,MKQ fun,'$CategoryFrame]]]) +---- MKQ parSignature,true,MKQ fun,'$CategoryFrame]]],$libFile) --Equivalent to the following two lines, we hope if null sargl then evalAndRwriteLispForm('NILADIC, diff --git a/src/interp/wi2.boot b/src/interp/wi2.boot index 77daa492..cb2d24c3 100644 --- a/src/interp/wi2.boot +++ b/src/interp/wi2.boot @@ -225,14 +225,14 @@ compDefineFunctor1(df, m,$e,$prefix,$formalArgList) == $lisplibSlot1 := $NRTslot1Info --NIL or set by $NRTmakeSlot1 $lisplibOperationAlist:= operationAlist $lisplibMissingFunctions:= $CheckVectorList - evalAndRwriteLispForm('"compilerInfo", + lisplibWrite('"compilerInfo", ['SETQ,'$CategoryFrame, ['put,['QUOTE,op'],' (QUOTE isFunctor), ['QUOTE,operationAlist],['addModemap,['QUOTE,op'],[' QUOTE,parForm],['QUOTE,parSignature],true,['QUOTE,op'], ['put,['QUOTE,op' ],'(QUOTE mode), - ['QUOTE,['Mapping,:parSignature]],'$CategoryFrame]]]]) + ['QUOTE,['Mapping,:parSignature]],'$CategoryFrame]]]],$libFile) if null argl then evalAndRwriteLispForm('NILADIC, ['MAKEPROP, ['QUOTE,op'], ['QUOTE,'NILADIC], true]) -- cgit v1.2.3