This commit is contained in:
ge
2026-05-01 22:23:43 +03:00
parent 80121031f9
commit 04a644869e
15 changed files with 10 additions and 60 deletions
+2
View File
@@ -1,6 +1,8 @@
# Binaries for programs and plugins # Binaries for programs and plugins
main main
netio netio
make
examples/*[^.v]
*.exe *.exe
*.exe~ *.exe~
*.so *.so
+7 -5
View File
@@ -2,12 +2,14 @@
`netio` is a flexible networking library for V programming language. `netio` is a flexible networking library for V programming language.
Differences with the V standard library `net` module: Features:
* Provides the low-level wrappers around C API. * Provides the low-level wrappers around C sockets API.
* Supports any kind of sockets, socket options, address families and protocols. * Supports any kind of sockets, socket options, address families and protocols.
* Working with network interfaces (limited for now).
The `netio.protocol` submodule provides access to the operatins system protocols database. * The `netio.protocol` submodule provides access to the operatins system protocols database.
`netio` is tested only on Linux, but should work on all POSIX-compliant operating systems. `netio` is tested only on Linux, but should work on all POSIX-compliant operating systems.
Microfost Windows support is not planned yet. Microsoft Windows support is not planned yet.
See examples/ dir in source code repository for usage examples.
View File
View File
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env -S v run #!/usr/bin/env v
import os import os
import rand import rand
-46
View File
@@ -1,46 +0,0 @@
#!/bin/sh
program_linux='
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
'
program_freebsd='
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
'
system=$(uname -s)
case $system in
Linux) PROGRAM=$program_linux;;
FreeBSD) PROGRAM=$program_freebsd;;
*) echo $0: $system is unsupported >&2; exit 1;;
esac
KIND=$1
KIND=${KIND:-"SocketType,SocketLevel,SocketOption,AddrFamily,AddrInfoFlag,NameInfoFlag,MsgFlag"}
echo module netio
echo
echo '/*'
echo -e "\tThis file is generated by mkconst.sh, DO NOT EDIT."
echo '*/'
echo
echo "$PROGRAM" | ${CC:-"cc"} -x c - -E -dM ${CFLAGS:-""} |
awk -v KIND=$KIND '
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
$2 ~ /^_/ {next}
$2 ~ /^[a-z]/ {next}
$2 ~ /^SOCK_/ && KIND ~ "SocketType" {printf "pub const %s = SocketType(C.%s)\n", tolower($2), $2}
$2 ~ /^(SOL|IPPROTO)_/ && KIND ~ "SocketLevel" {printf "pub const %s = SocketLevel(C.%s)\n", tolower($2), $2}
$2 ~ /^(SO|IP|IPV6)_/ && KIND ~ "SocketOption" {printf "pub const %s = SocketOption(C.%s)\n", tolower($2), $2}
$2 ~ /^AF_/ && KIND ~ "AddrFamily" {printf "pub const %s = AddrFamily(C.%s)\n", tolower($2), $2}
$2 ~ /^AI_/ && KIND ~ "AddrInfoFlag" {printf "pub const %s = AddrInfoFlag(C.%s)\n", tolower($2), $2}
$2 ~ /^NI_/ && KIND ~ "NameInfoFlag" {printf "pub const %s = NameInfoFlag(C.%s)\n", tolower($2), $2}
$2 ~ /^MSG_/ && KIND ~ "MsgFlag" {printf "pub const %s = MsgFlag(C.%s)\n", tolower($2), $2}
KIND ~ "Any" {printf "%s\n", $0}
{next}' | sort -k 2 -V
-5
View File
@@ -1,5 +0,0 @@
module netio
pub struct TCPListener {}
pub struct TCPStream {}
View File
-3
View File
@@ -1,3 +0,0 @@
module netio
pub struct UDPSocket {}