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.zipThe 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.