L3DT users' community
Large 3D terrain generator

Communication ZeoScript use <atTcpSock>

Correspondence concerning plugins and scripts; development, use, bugs and ideas.

Communication ZeoScript use <atTcpSock>

Postby armafromz » Mon May 27, 2013 6:20 am

I have just started learn to ZeoScript and find it very interesting. What I wan'na do is use the <atTcpSock> plugin to make L3DT connectable with my App, which also use winsock2 TCP/IP protocol.
Specifically, my goal is load some custom meshes such as planes into Sapphire 3D viewer, and use external data real-time driving these planes in motion.

External Data like an array [[pos_x,pos_y,pos_z],dir_o,[ver_x,ver_y,ver_z],[des_string],bla1,bla2,bla3...] send with winsock to L3DT pro.

here my questions:
1. <atTcpSock> is not available in L3DT v11.08 and above, I just load it in my old L3DT Pro v2.9, and it's worked. how to make it available in L3DT new versions?
2. I can use ZeoScript to load meshes into Sapphire 3D viewer, but I donn't know how to make a sleep in "do while" loop such as C++ use Sleep(200)?
3. The most critical problem is how to use these functions atTcpSock.Connect, atTcpSock.Accept, atTcpSock.Listen, atTcpSock.GetPeerAddr, atTcpSock.SendMsg, atTcpSock.SendMsgA, atTcpSock.GetRecvQueueSize.... correctly?
can you give me a example script?

I'd much appreciate it if anyone can help.
User avatar
armafromz
Newbie
 
Posts: 1
Joined: Mon May 27, 2013 4:37 am

Re: Communication ZeoScript use <atTcpSock>

Postby Aaron » Fri May 31, 2013 12:14 pm

Hi Armafromz,

I apologise for the delay in my reply. It's been a particularly hectic week.

1. <atTcpSock> is not available in L3DT v11.08 and above, I just load it in my old L3DT Pro v2.9, and it's worked. how to make it available in L3DT new versions?


An updated atTcpSock plugin is now available here:

http://www.bundysoft.com/L3DT/downloads ... ck-bin.zip

The socket functions have moved into the 'network.zSocket' namespace, e.g. 'network.zSocket.Connect'.

2. I can use ZeoScript to load meshes into Sapphire 3D viewer, but I donn't know how to make a sleep in "do while" loop such as C++ use Sleep(200)?


The latest build of L3DT Professional (13.5.0.0, on the downloads page now) supports the 'system.time.Sleep' script function. Here's the example script, which also uses GetTickCount to check on the duration of the sleep:

Code: Select all
// ask user to input delay period (default = 1000)
uint dwTarget
set dwTarget 1000
if <not <EditUI &dwTarget "Enter delay (milliseconds)">>
  return -1
endif

// get the tick count before
uint dwStart
set dwStart <system.time.GetTickCount>

// sleep
system.time.Sleep dwTarget

// get the tick count after
uint dwEnd
set dwEnd <system.time.GetTickCount>

// calculate the actual sleep time
uint dwElapsed
set dwElapsed <sub dwEnd dwStart>

// report to user
echo <strcat "Slept for " <strcat dwElapsed "ms">>


3. The most critical problem is how to use these functions atTcpSock.Connect, atTcpSock.Accept, atTcpSock.Listen, atTcpSock.GetPeerAddr, atTcpSock.SendMsg, atTcpSock.SendMsgA, atTcpSock.GetRecvQueueSize.... correctly?
can you give me a example script?


Tricky. atTcpSock was designed for use by plugins, not scripts, and some of the functions are not super-compatible with scripts. In particular, the asynchronous listen and receive functions can't be used without callback event handlers, which aren't exactly supported by ZeoScript (but are supported by the plugin API).

As it stands you could use scripts to connect to a server and send data, but there would be no way to accept an inbound connection or receive data into a script. I can provide example scripts for this if that's all you want, but I'm guessing you also want to receive data, and that will require some more work...

I could modify atTcpSock to handle synchronous sockets, which would allow scripts to listen and accept connections and receive data. However, these would be blocking calls, so if you tell the script to receive 20 bytes, it will halt until 20 bytes are received (or the connection is broken). I'm not sure that would necessarily fit with your design.

Another option would be to modify the atTcpSock plugin to allow scripts to be used as event callbacks, rather than plugin function handles. In this mode, you could provide a callback script to be called when a message is received, with the message passed through to the script. Likewise, you could provide a callback script for when a connection is received, which would then accept or reject the connection and begin communication. There will be a little bit of extra work in coordinating these separate scripts all acting on the same socket, but that's certainly doable. Hmmm...this seems the best option. I'll look into it.

I apologise for not having atTcpSock better sorted our for scripts. My initial enthusiasm for network render farming of L3DT petered out some time ago, and the atTcpSock plugin had seen little use since. However, your application sounds really interesting, so I guess it's a good time to blow the dust off atTcpSock and get it humming again. I'll let you know when I've got something ready to test.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3691
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Plugins and scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron