summaryrefslogtreecommitdiff
path: root/src/ivysocket.h
diff options
context:
space:
mode:
authorjacomi1998-08-12 10:23:25 +0000
committerjacomi1998-08-12 10:23:25 +0000
commitd3b04f0209ea826c67a2ee84ced889ee907f49a0 (patch)
treee0900dda136b9a9f38ee7b412db427a7315b06dc /src/ivysocket.h
parent6ff2ef5124e1101f475ad87b178b925489de2845 (diff)
downloadivy-c-d3b04f0209ea826c67a2ee84ced889ee907f49a0.zip
ivy-c-d3b04f0209ea826c67a2ee84ced889ee907f49a0.tar.gz
ivy-c-d3b04f0209ea826c67a2ee84ced889ee907f49a0.tar.bz2
ivy-c-d3b04f0209ea826c67a2ee84ced889ee907f49a0.tar.xz
version relookee en ivy
Diffstat (limited to 'src/ivysocket.h')
-rw-r--r--src/ivysocket.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/ivysocket.h b/src/ivysocket.h
new file mode 100644
index 0000000..2258caf
--- /dev/null
+++ b/src/ivysocket.h
@@ -0,0 +1,72 @@
+#ifndef _IVYSOCKET_H
+#define _IVYSOCKET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* general Handle */
+
+#define ANYPORT 0
+
+#ifdef WIN32
+#include <windows.h>
+#define HANDLE SOCKET
+#else
+#define HANDLE int
+#include <netinet/in.h>
+#endif
+
+
+/* Server Part */
+typedef struct _client *Client;
+typedef void (*SocketInterpretation)( Client client, void *data, char *ligne);
+
+extern void SocketInit();
+
+extern void SocketClose( Client client );
+extern void SocketSend( Client client, char *fmt, ... );
+extern void SocketSendRaw( Client client, char *buffer, int len );
+extern char *SocketGetPeerHost( Client client );
+extern void SocketSetData( Client client, void *data );
+extern void *SocketGetData( Client client );
+extern void SocketBroadcast( char *fmt, ... );
+
+extern int SocketServer(unsigned short port,
+ void*(*create)(Client client),
+ void(*handle_delete)(Client client, void *data),
+ SocketInterpretation interpretation);
+
+/* Client Part */
+
+extern Client SocketConnect( char * host, unsigned short port,
+ void *data,
+ SocketInterpretation interpretation,
+ void (*handle_delete)(Client client, void *data)
+ );
+extern Client SocketConnectAddr( struct in_addr * addr, unsigned short port,
+ void *data,
+ SocketInterpretation interpretation,
+ void (*handle_delete)(Client client, void *data)
+ );
+extern int SocketWaitForReply( Client client, char *buffer, int size, int delai);
+
+/* Socket UDP */
+/* Creation d'une socket en mode non connecte */
+/* et ecoute des messages */
+extern Client SocketBroadcastCreate(
+ unsigned short port,
+ void *data,
+ SocketInterpretation interpretation
+ );
+/* recuperation de l'emetteur du message */
+extern struct in_addr * SocketGetRemoteAddr( Client client );
+extern void SocketGetRemote( Client client, char **host, unsigned short *port );
+/* emmission d'un broadcast UDP */
+extern void SocketSendBroadcast( Client client, unsigned long host, unsigned short port, char *fmt, ... );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif