diff options
author | ihm | 1998-03-05 17:31:32 +0000 |
---|---|---|
committer | ihm | 1998-03-05 17:31:32 +0000 |
commit | dc706ef662bda4a843aa088696132078472400d5 (patch) | |
tree | 0d877ea0200e0603f48c65fa2cf9cb6a4854edb0 /socket.h | |
parent | 23abb4b87c7e40ed259dd02f653516f60e55ade4 (diff) | |
download | ivy-c-dc706ef662bda4a843aa088696132078472400d5.zip ivy-c-dc706ef662bda4a843aa088696132078472400d5.tar.gz ivy-c-dc706ef662bda4a843aa088696132078472400d5.tar.bz2 ivy-c-dc706ef662bda4a843aa088696132078472400d5.tar.xz |
Initial revision
Diffstat (limited to 'socket.h')
-rw-r--r-- | socket.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/socket.h b/socket.h new file mode 100644 index 0000000..99b9abd --- /dev/null +++ b/socket.h @@ -0,0 +1,87 @@ +#ifndef _SOCKET_H +#define _SOCKET_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 + +typedef struct _channel *Channel; + +extern void ChannelInit(void); +extern void ChannelStop(void); +extern void ChannelMainLoop(void(*hook)(void) ); +extern Channel ChannelSetUp( + HANDLE fd, + void *data, + void (*handle_delete)( void *data ), + void (*handle_read)( Channel channel, HANDLE fd, void *data) + ); + +extern void ChannelClose( Channel channel ); + +/* Server Part */ +typedef struct _client *Client; +typedef void (*SocketInterpretation)( Client client, void *data, char *ligne); + +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 XTMAINLOOP +extern void SetSocketAppContext( XtAppContext cntx ); +#endif + +#ifdef __cplusplus +} +#endif + +#endif |