Other than setting up the message that is being sent my whole code is
just a few lines. As far as maintaining it, other than changing the IP
or port as needed there shouldn't be anything that would ever change.
You might need to increase the ack wait time for some interfaces, but
other than that the code should just work.
I'm sure that using %Z.tcp.close(9) would than the CL(!U) that I'm
using. It just calls $DEV.C(A) so you could also use $DEV.C(9). That
should properly shut down the connection as opposed to CL(!U) which
just cuts it off. However I've been using this code as it is since
2004 and have not had a single problem with it as long as the
receiving system is actually listening.
It looks like your code is checking timeouts and then for a specific
text string in ![/LEN] to know if the message was sent. All you really
need to do is check for an ack at the end. If you get one then all is
well. If you don't then it doesn't matter if it timed out or dropped
or whatever, the message did not get thru. That's all you're returning
in /R.FRAG.VAL anyway - OK or nil.
I think s is the saf containing the data received back from the
listening system which should be the ack. I have no reference for that
other than seeing how it's used in various programs. @tcp.connection
translates as /Z.TCP.CONN. It is nil if the connection failed and the
connection number if the connection was successful. It should contain
the same data as !s|2. You can still reference !s|1 and ![/LEN] as you
have been doing, but I don't see the point. The fewer things for
someone else to get confused by the better.
CL(!S),
%Z.tcp.open(9,IP,PORT),
D(11)^!,
@SEND.MESSAGE,
D(28,13)^!,
@GET.ACKNOWLEDGEMENT,
CL(!U)
GET.ACKNOWLEDGEMENT
0^/ACK,""^ZKRH,
DO{(/ACK<3)&('ZKRH)&(@RUN) H(5),>!^ZKRH,/ACK+1^/ACK},
IF{>! ![>!]^ZP;"ERROR"^FAIL}
RUN
(!s|1)'=0'=4'=6'=9
SEND.MESSAGE
/MSH_D(13)^!,
/PID_D(13)^!,
etc
>
steven.m...@nbrhc.on.ca
> *O[""](!,"i"_/IP_"p"_/PORT_IF{F
> "l"_F}_"e"_255.255.255.255.255.255_"I8")^XXX,*
> I...@IP.ADDRESS B;
> %
Z.tcp.name(B)}^B,
> IF{'A!'B!'C "";
> "i"_B_"p"_C_IF{D "l"_D}_"e"_@ETH_"I8"^X,
> V("O("_("#$%&*?\/:!"#A^p)_",X)")^X,
> 'X V("C("_p_")"),"";
> V(p_"s|2")}...@tcp.connection;
> ETH
> 255.255.255.255.255.255
> IP.ADDRESS
> B^X,0^x,DO{IF{X#0.?0N^y!0&255=y x+1^x,X'$1.^X}},
> x=4&'X
> On Fri, Feb 3, 2012 at 1:46 PM, Tom Tarbotton <
blackcatsma...@gmail.com>wrote:
>
>
>
>
>
>
>
> > If you really want an explanation of the code I can work thru it for
> > you. I did that a few years ago when I needed to write my own tcp
> > interface from OE. But there's an easier way with no syntax checker
> > issues - a Z program that does it for you - Z.tcp.open. You just need
> > to pass in 3 arguments - prefix, IP, and port. The 4th argument -
> > local port - is optional. For prefix I use 9 which crresponds to !. So
> > an example call would be %Z.tcp.open(9,/IP,/PORT)
>
> > ;A= ^prefix
> > ;B= IP address or computer name to open to
> > ;C= Port to go to
> > ;D= local port (not required)
>
> > On Feb 3, 1:18 pm, Steve Mogg <
sjm...@gmail.com> wrote:
> > > Hello Everyone,
>
> > > Does anyone have documentation for using the OPEN command, or O, to
> > > open a connection to another server?
> > > O[“”](!,"i"_/IP_"p"_/PORT_IF{F "l"_F}
> > > _"e"_255.255.255.255.255.255_"I8")^XXX,
>
> > > I had to modify a report to fool the syntax checker using the above
> > > syntax. I got the report working but I would like to understand the
> > > code that opens to a remote computer (We have a custom report that
>
> ...
>
> read more »