home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 March
/
Chip_2002-03_cd2.bin
/
dmbsck.cab
/
dumb_socket.h
< prev
Wrap
C/C++ Source or Header
|
2001-10-22
|
3KB
|
118 lines
#ifndef __DUMB_SOCKET_H
#define __DUMB_SOCKET_H
#ifndef __DUMB_SOCKET
#define __DUMB_SOCKET
#endif
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the DUMB_SOCKET_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// DUMB_SOCKET_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifndef DUMB_SOCKET_API
#ifdef DUMB_SOCKET_EXPORTS
#define DUMB_SOCKET_API __declspec(dllexport)
#else
#define DUMB_SOCKET_API __declspec(dllimport)
#endif
#endif
/*
// This class is exported from the dumb_socket.dll
class DUMB_SOCKET_API CDumb_socket {
public:
CDumb_socket(void);
// TODO: add your methods here.
};
extern DUMB_SOCKET_API int nDumb_socket;
DUMB_SOCKET_API int fnDumb_socket(void);
*/
#define I_AM_CLIENT 0
#define I_AM_SERVER 1
#define BLOCKING 1
#define NONBLOCKING 0
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _dumbs_item {
void* data;
int size;
struct _dumbs_item* next;
struct _dumbs_item* prev;
int locked;
CRITICAL_SECTION lock;
} dumbs_item;
typedef struct _dumb_socket {
dumbs_item *first;
dumbs_item *last;
short blocking;
HANDLE block_sem;
#if _DEBUG
int locked;
#endif
CRITICAL_SECTION lock;
struct _dumb_socket *next_zombie;
} dumb_socket;
#define NONAME_PIPE /* testik */
typedef struct _dumb_pipe {
struct _dumb_socket* dumb_sock[2];
short connected;
#ifndef NONAME_PIPE
char *name;
#endif
short blocking;
HANDLE connect_synchro;
// HANDLE exclusive_synchro;
struct _dumb_pipe* next;
} dumb_pipe;
typedef struct _hdumb_pipe {
short server;
dumb_pipe* pipe;
} hdumb_pipe;
void DUMB_SOCKET_API destroy_dumb_pipe(hdumb_pipe* h);
//DUMB_SOCKET_API hdumb_pipe* _create_dumb_pipe(int i_am_server, int blocking, char* name);
DUMB_SOCKET_API hdumb_pipe* create_client_dumbpipe(char *name);
DUMB_SOCKET_API hdumb_pipe* create_server_dumbpipe(short blocking, char *name);
DUMB_SOCKET_API int connect_hdumb_pipe(hdumb_pipe* h);
DUMB_SOCKET_API hdumb_pipe* duplicate_hdumb_pipe(hdumb_pipe* p);
DUMB_SOCKET_API int read_dumb_pipe(hdumb_pipe* h,char* buff,int buf_size);
DUMB_SOCKET_API int write_dumb_pipe(hdumb_pipe* h,char* buff,int size);
DUMB_SOCKET_API void destroy_dumb_pipe(hdumb_pipe* p);
DUMB_SOCKET_API int wait_hdumb_pipe(char *name,int timeout);
#ifdef MYSQL_SERVER
#define WHO_AM_I I_AM_SERVER
//#define BLOCK(x) x
#else
#define WHO_AM_I I_AM_CLIENT
//#define BLOCK(x) NONBLOCKING
#endif
//#define create_dumb_pipe(x,name) _create_dumb_pipe(WHO_AM_I,BLOCK(x),name)
#ifdef __cplusplus
}
#endif
#endif