aboutsummaryrefslogtreecommitdiff
path: root/net/net.h
diff options
context:
space:
mode:
authorjacopo grandi <jak.sk8@hotmail.it>2021-02-18 14:14:23 +0100
committerjacopo grandi <jak.sk8@hotmail.it>2021-02-18 14:14:23 +0100
commit5f0fce4191309e9526b7109a0d87c092ce6a4193 (patch)
tree105257f876551814aa74a0760ec116bd1bf307a5 /net/net.h
parentead78d51e662057467b79d3a65b20c4ba83cbf07 (diff)
main
Diffstat (limited to 'net/net.h')
-rw-r--r--net/net.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/net/net.h b/net/net.h
new file mode 100644
index 0000000..056114b
--- /dev/null
+++ b/net/net.h
@@ -0,0 +1,35 @@
+#ifndef NET_H
+#define NET_H
+
+#include <plibsys.h>
+
+#define SERVER_PORT 9999
+
+void itob (char *buf, int n);
+int btoi (char *buf);
+
+void net_init ();
+
+typedef struct {
+ PSocket *socket;
+ PSocketAddress * addr_server;
+} net_client;
+
+void net_client_open(net_client *c);
+int net_client_connect (net_client *c, char ip[], int port);
+int net_client_recv(net_client *c, char buffer[]);
+void net_client_send (net_client *c, char data[], int sizeofdata);
+void net_client_close (net_client *c);
+
+typedef struct {
+ PSocket *socket;
+ PSocket *sock_client;
+} net_server;
+
+void net_server_open(net_server *s, int port);
+void net_server_accept(net_server *s);
+int net_server_recv(net_server *s, char buffer[]);
+void net_server_send (net_server *s, char data[], int sizeofdata);
+void net_server_close (net_server *s);
+
+#endif \ No newline at end of file