Current version: 0.17.x
»GeeXLab homepage

Current version: 1.19.1
»FurMark homepage
»FurMark 1.9.x Submissions

GPU Caps Viewer
Current version:
»GPU Caps Viewer homepage
»GPU DB Submissions

GPU Shark
Current version:
»GPU Shark homepage

»JeGX's HackLab

Geeks3D's Articles
»GPU Memory Speed Demystified

»Multi-Threading Programming Resources

»GeForce and Radeon OpenCL Overview

»How to Get your Multi-core CPU Busy at 100%

»How To Make a VGA Dummy Plug

»Night Vision Post Processing Filter

PhysX FluidMark
Current version: 1.5.2
»FluidMark homepage
»FluidMark 1.4.x Submissions

Current version: 0.3.0
»TessMark homepage

Current version: 0.3.0
»ShaderToyMark homepage
»ShaderToyMark Scores

Current Version: 1.23.0
»Libraries and Plugins
»Online Help - Reference Guide
»Codes Samples

3D Graphics Search Engine:

The Geeks Of 3D

The LUA SocketLib and the Coroutines

By Jerome Guinot aka 'JeGX' - jegx_AT_ozone3d(dot)net

Initial draft: May 2, 2006

[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Page 5

5 - La démo

First, a little screenshot:

The demo that comes with this tutorial allows to drive the rotation of a torus by changing the 3 Euler's angles: pitch, yaw and roll. The interesting thing is that the Euler's angles modification is done by a remote all-purposes TCP client:

The TCP client's functioning is hyper-simple: just enter the server name (characters string representing the hostname or IP address - ex: 127.0.01 or HyperionServer), the server's port and the message to be sent. The TCP client adds automatically a '\n' at the end of the message in order to respect the server protocol. Then, [Send Message] allows to send the message to the server. The checkbox allows to wait for a server reply. The demo's TCP server returns to the client the HYP_OK string if the client has sent a valid command or HYP_UNKNOWN_COMMAND in case of invalid command.

Load the DEMO_LUA_TCP_Server_Coroutine.xml file in Hyperion and start the TCP client. Then send, from the client, the following command:

pitch +100.0

The torus angular speed is now equal to 100.0 degrees / second. The general format of the command is:

pitch +/-[value] +/-yaw [value] +/-roll [value]

The following commands are all valid:

pitch +100.0 roll -20.0
yaw -50.0

This little demo allows us to use a very handy function of the LUA string lib: string.gmatch(). This function allows to analyze the client message and look up the Euler's angles (in 3 global variables):

function extractEulerAngles( command )
  local ok = 0;
  for angle_name, angle_value in string.gmatch(command, "(%a+) (%p%d+%p%d+)") do
      if angle_name=="pitch" then
        g_pitch_step = tonumber(angle_value);
        ok = 1;

      elseif angle_name=="yaw" then
        g_yaw_step = tonumber(angle_value);
        ok = 1;

      elseif angle_name=="roll" then
        g_roll_step = tonumber(angle_value);
        ok = 1;



Each call to string.gmatch() analyzes the command string pattern by pattern. In our case, the pattern is (%a+) (%p%d+%p%d+).

The pattern (%a+) allows to extract the angle's name (pitch, yaw or roll) and stores this name in the angle_name variable. The pattern (%p%d+%p%d+) allows to extract the angle's value in order to store it in angle_value.

For example, the pitch +100.0 roll -20.0 yaw +10.0 command contains 3 patterns and pitch +100.0 contains only one.

I don't get deeper into the detail, please see the LUA 5.1 reference guide available at for more information about patterns.

6 - Further reading

7 - Downloads

Demoniak3D project
Last update: May 5, 2006

*** These source codes require Demoniak3D to run properly.
Demoniak3D is available here: [:: Demoniak3D Demo-System ::].

All purposes Win32 TCP Client
Mise à jour: May 5, 2006

LUA SocketLib Official Doc

[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Page 5

GeeXLab demos

GLSL - Mesh exploder

PhysX 3 cloth demo

Normal visualizer with GS

Compute Shaders test on Radeon

Raymarching in GLSL

Geeks3D latest news

Geeks3D forum news

»Texture DataPack #1
»Asus Silent Knight CPU Cooler
Page generated in 0.0068600177764893 seconds.