Storyboard IO TCP/IP Relay Application for Mobile Platforms

New to Storyboard 4.0, we've added the GREIO plugin to iOS and improved custom plugin support on mobile platforms. Attached are two sample applications that demonstrate the Storyboard IO TCP/IP functionality talked about in this post for Android and iOS. Review that post to understand the purpose of the TCP/IP connection and look at the C code involved.

As a brief overview, the tcp_client application has a simple button that, when touched, will execute the send_event_outbound Lua function and send a custom 'HelloOutThere' event to the channel 'outbound', which the client is listening on. The client will take that event and pass it on to the server, who will, in turn, pass it to the channel it is listening on, which should be the tcp_server application channel. The tcp_server application is listening for the 'HelloOutThere' event and will call the Lua function received_event which will display the event data on the screen.

To have the samples run properly, there are a few things to make sure to do when exporting the application to iOS/Android. Under 'Storyboard Runtime Options' in the export dialog, make sure to set the channel name for the server application (-ogreio,channel=<name>). This should be the same name sent into the call to init_server. When exporting to Android, you need to add the 'android.permission.INTERNET' permission in order to successfully set up the connection, which you can do under 'Advanced Options'. You also need to set the 'Shared Object List Location' to be the path to user_libs.txt, found at the root of the project. This informs the exporter that there are custom libraries to load and tells it where they are. Once the applications are exported properly, make sure to run the server application first or the client won't have anything to connect to.

The samples can be adapted to work on other operating systems as well. For that, you will need to re-compile sbio_tcprelay.c into a shared object for whatever environment you are in. I've attached a sample Makefile which you can change to build for your environment. You will need to change the SB_ROOT variable to contain the absolute path to the runtime you want to use. You may also need to change the CC variable to the appropriate compiler, as well as add any OS specific CFLAGS or LDFLAGS necessary.




  • The post that I referenced above links to code for the TCP/IP relay as a standalone application, but a Lua module is needed for use in the manner described here. Attached is an extension of the original sbio_relay.c that includes the Lua connection required for the examples in this post.


  • Hi Evan,

    Thank you for this post. i just complied sbio_tcprelay.c. What I get as output is the sbio_tcprelay.o and I don't understand should I get an executable file as output? How should I use the object file sbio_tcprelay.o? 

    The tcp_server will be deployed in Android and the tcp_client in Linux machine. The previous example in this post I understand that I should use the command line to start both client and server, but in this case, I don't understand how to do it.

    Thank you!

    All the best,


  • Hi,

    The code that Evan linked last was for a TCP relay Lua module when compiled this would simply be a shared object (.so) that Lua will load. Because you want to run the server on Android you will need to use the TCP relay Lua module on that end, there’s an example of how to run the server in this way in (available above). The example is straight forward, callbacks.lua shows how to load the TCP relay library, initialize the connection, and receive an event. You will need to add this library to a user libs file when you export your APK, you can find out how to do this in our documentation ( ... ml#d0e5683). 

    On your Linux machine, you could probably just use the command line TCP relay.


    Matt L

  • Hi,

    Thank you, Matt, for the information. I tried your suggestion and it worked. 

    I have a question regarding bidirectional communication between the server and client, for example, if I want to send an event from tcp_server to tcp_client. As I know tcp_sever can write to the client only if it has received a request, but in my case, I want to send an event from tcp_sever to tcp_client without client request. Is there some way how can I approach this bidirectional communication?

    Thank you!

    All the best,


  • Hi 

    - Thank you for addressing this interesting topic about communication via TCP/IP.

    I tried to use the example above to make simple chatting between PC platform ( as a server ) and Android app ( as a client ) with connection successful, but my problem is I can't send or received data (text string)!

    because I using Win10 64bit, changed SB include and lib like this :

    CC=qcc -Vgcc_ntox86
    SB_INCLUDE=-I"C:\Program Files (x86)\Crank_Software\Storyboard_Engine\5.1.201707240438\android-armle-opengles_2.0-obj\include"
    SB_LIB=-L"C:\Program Files (x86)\Crank_Software\Storyboard_Engine\5.1.201707240438\android-armle-opengles_2.0-obj\lib" -lgreio -lsocket

    I missing something ... any help!


  • Hello Riyadh

    What target (Windows, Linux, Mac) are you trying to compile your binaries for the PC platform?

    The reason I ask is that you have mixed and matched your compile lines in what you have posted. The include and lib lines that you are using are for an Android armle platform, but the compiler you are using is core a QNX x86 system. 


  • Hi rdowdall

    Thanks for your reply ... yes I working on windows, my target is Android platform *.apk by Storyboard, as chatting between PC( as server by ) and Android platform app ( as client by storyboard ) I want to know how I use TCP/IP to send and received data, when I turn on client app on android device the server connected directly on client , but I can't send or received between them

    in the example above ( the name of the event does not exist on sbio_tcprelay.c ?? how event work with sbio_tcprelay .c?
    - I make successful connected TCP/IP ( as img), but I cant transfer data, how I can make it ??

    function send_event_outbound(mapargs)
    local event_data = {data1 = "somdata1", data2 = "somdata2"}
    local format = "1s0 data1 1s0 data2"
    gre.send_event_data("HelloOutThere", format, event_data, "outbound")


  • Hello Riyadh

    The TCP relay that we are using in this example is a cover for using Storyboard IO through a TCP connection. Your server probably doesn't know anything about Storyboard IO, so it isn't really going to be able to do anything with the connection that you are setting up from the Storyboard application. 

    For what you are trying to do, I would recommend something like Lua sockets. More information on Lua sockets can be found here:


Please sign in to leave a comment.

Didn't find what you were looking for?

New post