English [LuaJIT/LuaFFI] Socket Support icon

14 comments
21.06.15 07:18:15 pm
like 4 like it!
5 kb, 80 Downloads
Starkkz
Moderator
Offline Off
Hello there people! Since we just got LuaJIT on Counter-Strike 2D 0.1.2.6, I'd like to release a socket library for your purposes. The only dynamic libraries necessary for this are integrated in your operating system.

• The up to date files are stored on this github repository
https://github.com/Starkkz/bnet

How to load has written:
1. Extract bnet.lua in your CS2D root folder
2. Load with require
Code:
1
require("bnet")


IMG:http://i.imgur.com/VWSDLtn.png

IMG:http://i.imgur.com/kxPAIZh.png

• TTCPStream: Base class for TCP sockets
IMG:http://i.imgur.com/Us5SXF6.png

TTCPStream:ReadByte() -> number 8 bit value
TTCPStream:ReadShort() -> number 16 bit value
TTCPStream:ReadInt() -> number 32 bit value
TTCPStream:ReadLong() -> unit64_t cdata 64 bit value
TTCPStream:ReadLine() -> string Line
TTCPStream:ReadString(number Length) -> string String
TTCPStream:WriteByte(number Byte)
TTCPStream:WriteShort(number Short)
TTCPStream:WriteInt(number Integer)
TTCPStream:WriteLong(number/uint64_t Long)
TTCPStream:WriteLine(string Line)
TTCPStream:WriteString(string String)
TTCPStream:Connected() -> boolean Connected
TTCPStream:Size() -> number Size
TTCPStream:Eof() -> boolean EndOfFile
TTCPStream:Close()
TTCPStream:Timeouts(number Read, number Accept)

• TUDPStream: Base class for UDP sockets
IMG:http://i.imgur.com/Us5SXF6.png

TUDPStream:ReadByte() -> number 8 bit value
TUDPStream:ReadShort() -> number 16 bit value
TUDPStream:ReadInt() -> number 32 bit value
TUDPStream:ReadLong() -> unit64_t cdata 64 bit value
TUDPStream:ReadLine() -> string Line
TUDPStream:ReadString(number Length) -> string String
TUDPStream:WriteByte(number Byte)
TUDPStream:WriteShort(number Short)
TUDPStream:WriteInt(number Integer)
TUDPStream:WriteLong(number/uint64_t Long)
TUDPStream:WriteLine(string Line)
TUDPStream:WriteString(string String)
TUDPStream:Size() -> number ReceivedSize
TUDPStream:Eof() -> boolean EndOfFile
TUDPStream:Close()
TUDPStream:SendTo(string IP, number Port) -> boolean Sent
TUDPStream:RecvFrom() -> string IP, number Port
TUDPStream:Timeout(number Receive)

IMG:http://i.imgur.com/iYKBVNo.png

bnet.IntIP(string IP) -> number IP     
bnet.StringIP(number IP) -> string IP
bnet.CreateUDPStream(number Port) -> TUDPStream Stream
bnet.CloseUDPStream(TUDPStream Stream)
bnet.UDPMsgIP(TUDPStream Stream) -> string SourceIP
bnet.UDPMsgPort(TUDPStream Stream) -> number SourcePort
bnet.UDPStreamIP(TUDPStream Stream) -> string LocalIP
bnet.UDPStreamPort(TUDPStream Stream) -> number LocalPort
bnet.OpenTCPStream(string IP, number Port, number LocalPort) -> TTCPStream Stream
bnet.TCPStreamConnected(TTCPStream Stream) -> boolean Connected
bnet.CloseTCPStream(TTCPStream Stream)
bnet.CreateTCPServer(number Port) -> TTCPStream Stream
bnet.AcceptTCPStream(TTCPStream Server) -> TTCPStream Client
bnet.TCPStreamIP(TCPStream Stream) -> string IP
bnet.TCPStreamPort(TCPStream Stream) -> number Port

> Tests
√ Windows 8 Pro x64
× Linux (I need someone to test it)
edited 12×, last 17.01.16 09:47:23 pm
x This file has been reviewed and declined by DC (13.12.18 11:55:35 pm)
Outdated

Comments

14 comments
Goto Page
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in
07.02.17 12:01:35 am
Up
Starkkz
Moderator
Offline Off
@Any reviewer: please decline this file, it's currently outdated and there are some LuaSocket binaries on the File Archive.
06.02.17 03:38:04 pm
Up
MikuAuahDark
User
Offline Off
Just sayin, this only work for (and only for) CS2D b0.1.2.6, since that version uses LuaJIT. Later version revert back to Lua 5.1.4 due to incompatibilities provided by it.
26.12.16 04:51:01 pm
like I like it!
Up
lilyagirl123
User
Offline Off
Very usefull for me!, Nice 5/5.
24.06.15 08:38:12 pm
Up
Starkkz
Moderator
Offline Off
@user Hajt: Sorry, the library is a bit damaged, we're trying to code a replacement for. (I and user mafia_man)
Code:
1
2
3
4
FD_ISSET
FD_SET
FD_ZERO
etc..

On linux.
24.06.15 06:29:06 pm
Up
Hajt
User
Offline Off
Code:
1
LUA ERROR: ./bnet.lua:175: sys/socket.h: cannot open shared object file: No such file or directory

Ubuntu 14.04 LTS
22.06.15 10:02:35 pm
like I like it!
Up
Avo
User
Offline Off
Thank you!
21.06.15 11:52:57 pm
like I like it!
Up
JeeewNazi
User
Offline Off
I was looking for this for long,
As i said in the private message,
Thank You,
21.06.15 11:10:11 pm
Up
MikuAuahDark
User
Offline Off
It doesn't exist because FFI library is added in LuaJIT 2.0.0 beta-6 while CS2D uses LuaJIT 2.0.0 beta-4 (print(jit.version)). Better talk to user DC to use LuaJIT 2.0.0 or above instead
21.06.15 11:01:35 pm
Up
Starkkz
Moderator
Offline Off
@user MikuAuahDark: That was supposed to be included automatically, but we'll find this out, I'm talking to user DC about it.
21.06.15 10:53:24 pm
Up
MikuAuahDark
User
Offline Off
Code:
1
LUA ERROR: sys/lua/bnet.lua:1: module 'ffi' not found

Looks like user DC doesn't add FFI library into CS2D
21.06.15 09:48:43 pm
like I like it!
Up
Marcell
Super User
Offline Off
Thanks dude
21.06.15 08:14:48 pm
Up
Starkkz
Moderator
Offline Off
@user Fraizeraust: is right, it's for any windows but I tested it on my computer. It should also run on Linux but someone has to test it, I don't even have a Linux VM nor a server.
21.06.15 08:11:56 pm
Up
Fraizeraust
Moderator
Offline Off
@user -SaZ- And -Energy- Amanda: Actually, he made a test with this library on Windows 8 but is compatible with other Win OSs too obviously (if user Starkkz prove me that I'm right ).
21.06.15 08:09:15 pm
Up
This lua Only Win 8 ??? And
Win XP , is work ??
To the start Previous 1 Next To the start