From 8020a76c4153f4d276f777ed230a8b2173d65408 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sun, 27 Nov 2022 19:59:42 -0600 Subject: [PATCH] changed tcpserver signature --- AST.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/AST.cs b/AST.cs index 97f6dcb..042f7a8 100644 --- a/AST.cs +++ b/AST.cs @@ -1054,10 +1054,15 @@ namespace langtest Expression listenIp = expressions[0]; Expression listenPort = expressions[1]; VariableGetValueNode? stream_name = expressions[2] as VariableGetValueNode; - Expression exp = expressions[3]; + VariableGetValueNode? ip_name = expressions[3] as VariableGetValueNode; + + Expression exp = expressions[4]; + if(stream_name == null) throw new Exception("You must use identifier at positional arg #3 (starting from 1)"); + if(ip_name == null) throw new Exception("You must use identifier at positional arg #4 (starting from 1)"); string name = stream_name.Name; - //tcpserver("0.0.0.0",4202,strm,{}) + string ipname = ip_name.Name; + //tcpserver("0.0.0.0",4202,strm,ip,{}) TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse(state.BoxToString(listenIp.Evaluate(state))),(int)listenPort.Evaluate(state))); listener.Start(); while(true) @@ -1067,6 +1072,10 @@ namespace langtest var s=state.NewScope(); long str =s.CreateStream(stream); s.SetVariable(name,str); + string? ip=clt.Client?.RemoteEndPoint?.ToString(); + if(string.IsNullOrWhiteSpace(ip)) ip=""; + + s.SetVariable(ipname,s.CreateBox(ip)); exp.Execute(s); s.CloseStream(str); }