aboutsummaryrefslogtreecommitdiff
path: root/client/helloworld/net.h
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-07-26 17:36:20 -0700
committerTrumeet <yuuta@yuuta.moe>2022-07-26 17:36:20 -0700
commit7099a86ca74fa637f26af38674f80fb8efd5f6fa (patch)
tree33315c65e82170476cf3c80d976dfa4d16a304a3 /client/helloworld/net.h
parent8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2 (diff)
downloadacron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar
acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar.gz
acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.tar.bz2
acron-7099a86ca74fa637f26af38674f80fb8efd5f6fa.zip
refactor(libacron/acronc/helloworld): move to separate directories
The corresponding CMakeLists.txt files are still rough.
Diffstat (limited to 'client/helloworld/net.h')
-rw-r--r--client/helloworld/net.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/client/helloworld/net.h b/client/helloworld/net.h
new file mode 100644
index 0000000..1a49709
--- /dev/null
+++ b/client/helloworld/net.h
@@ -0,0 +1,45 @@
+/*
+ * Created by yuuta on 7/23/22.
+ */
+
+#ifndef ACRONC_NET_H
+#define ACRONC_NET_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef WIN32
+#include <winsock2.h>
+
+#else
+
+#define SOCKET int
+
+#endif
+
+#define NET_CLOSED -2
+#define NET_TIMEOUT -1
+
+int net_connect(const char *host,
+ uint16_t port,
+ SOCKET *sock);
+
+int net_read(const SOCKET *sock,
+ void *buffer,
+ size_t length,
+ size_t *read,
+ unsigned int timeout);
+
+int net_send(const SOCKET *sock,
+ const void *buffer,
+ size_t len);
+
+void net_close(const SOCKET *sock);
+
+int net_init(void);
+
+void net_free(void);
+
+char *net_strerror(int errnum);
+
+#endif /* ACRONC_NET_H */