aboutsummaryrefslogtreecommitdiff
path: root/src/externs
diff options
context:
space:
mode:
authorrc_05 <contact@rc-05.com>2024-05-24 23:03:55 +0200
committerrc_05 <contact@rc-05.com>2024-05-25 00:58:25 +0200
commit2095935c2488d1a46c7dd0c9d2325e41715b8ad9 (patch)
tree9761c6b5956d9b89e37a1eb6630ba63d39a8128a /src/externs
downloadhaxe-unix-sockets-2095935c2488d1a46c7dd0c9d2325e41715b8ad9.tar.gz
First commit1.0.0
Diffstat (limited to 'src/externs')
-rw-r--r--src/externs/Build.xml9
-rw-r--r--src/externs/Socket.cpp.hx32
2 files changed, 41 insertions, 0 deletions
diff --git a/src/externs/Build.xml b/src/externs/Build.xml
new file mode 100644
index 0000000..312314f
--- /dev/null
+++ b/src/externs/Build.xml
@@ -0,0 +1,9 @@
+<xml>
+ <section>
+ <files id="haxe" if="linux">
+ <compilerflag value="-I/usr/include"/>
+ <compilerflag value="-L/usr/lib"/>
+ <compilerflag value="-L/usr/lib64"/>
+ </files>
+ </section>
+</xml>
diff --git a/src/externs/Socket.cpp.hx b/src/externs/Socket.cpp.hx
new file mode 100644
index 0000000..6103cea
--- /dev/null
+++ b/src/externs/Socket.cpp.hx
@@ -0,0 +1,32 @@
+package externs;
+
+import cpp.Void;
+import cpp.SizeT;
+import cpp.Star;
+import cpp.Int32;
+import cpp.ConstStar;
+import cpp.ConstCharStar;
+
+@:include("sys/socket.h")
+@:native("struct sockaddr")
+@:structAccess
+extern class SockAddr {}
+
+@:include("sys/un.h")
+@:native("struct sockaddr_un")
+@:structAccess
+extern class SockAddrUnix {}
+
+@:buildXml("<include name='${haxelib:haxe-unix-sockets}/src/externs/Build.xml'/>")
+@:include("unistd.h")
+@:include("sys/socket.h")
+extern class Socket {
+ @:native("socket") static function socket(domain:Int32, type:Int32, protocol:Int32):Int32;
+ @:native("bind") static function bind(sockfd:Int32, addr:ConstStar<SockAddr>, addrlen:Int32):Int32;
+ @:native("listen") static function listen(sockfd:Int32, backlog:Int32):Int32;
+ @:native("accept") static function accept(sockfd:Int32, addr:Star<SockAddr>, addrlen:Star<Int32>):Int32;
+ @:native("connect") static function connect(sockfd:Int32, addr:ConstStar<SockAddr>, addrlen:Int32):Int32;
+ @:native("read") static function read(fd:Int32, buf:Star<Void>, count:SizeT):SizeT;
+ @:native("write") static function write(fd:Int32, buf:ConstStar<Void>, count:SizeT):SizeT;
+ @:native("close") static function close(fd:Int32):Int32;
+}