[vlc-commits] commit: Lua: Implement net.connect_tcp (Srikanth Raju )

git at videolan.org git at videolan.org
Sat Mar 20 18:34:43 CET 2010


vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Thu Mar 11 20:34:40 2010 +0530| [2bb90c75bebf9e55925cf087bc980ef83005d27c] | committer: Jean-Philippe André 

Lua: Implement net.connect_tcp

Signed-off-by: Jean-Philippe André <jpeg at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2bb90c75bebf9e55925cf087bc980ef83005d27c
---

 modules/misc/lua/libs/net.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/modules/misc/lua/libs/net.c b/modules/misc/lua/libs/net.c
index 90eec66..b8d3091 100644
--- a/modules/misc/lua/libs/net.c
+++ b/modules/misc/lua/libs/net.c
@@ -45,6 +45,7 @@
 #endif
 #include <sys/stat.h>
 
+#include<errno.h>
 #include "../vlc.h"
 #include "../libs.h"
 
@@ -150,6 +151,16 @@ static int vlclua_net_accept( lua_State *L )
 /*****************************************************************************
  *
  *****************************************************************************/
+static int vlclua_net_connect_tcp( lua_State *L )
+{
+    vlc_object_t *p_this = vlclua_get_this( L );
+    const char *psz_host = luaL_checkstring( L, 1 );
+    int i_port = luaL_checkint( L, 2 );
+    int i_fd = net_Connect( p_this, psz_host, i_port, SOCK_STREAM, IPPROTO_TCP );
+    lua_pushinteger( L, i_fd );
+    return 1;
+}
+
 static int vlclua_net_close( lua_State *L )
 {
     int i_fd = luaL_checkint( L, 1 );
@@ -339,6 +350,7 @@ static int vlclua_opendir( lua_State *L )
 static const luaL_Reg vlclua_net_reg[] = {
     { "url_parse", vlclua_url_parse },
     { "listen_tcp", vlclua_net_listen_tcp },
+    { "connect_tcp", vlclua_net_connect_tcp },
     { "close", vlclua_net_close },
     { "send", vlclua_net_send },
     { "recv", vlclua_net_recv },



More information about the vlc-commits mailing list