⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hatcp.h

📁 extremeDB s sample code,useful for you
💻 H
字号:
/******************************************************************* *                                                                 * *  This file is a part of the eXtremeDB-HA Application Framework  * *  Copyright (c) 2001-2006 McObject LLC                           *  *  All Rights Reserved                                            * *                                                                 * *******************************************************************//** *\file hatcp.h * ++ *\brief      definitions of TCP sockets IPC *  * PROJECT:   eXtremeDB(tm) (c) 2003 McObject LLC * * SUBSYSTEM: HA support * * MODULE:    hatcp.h * * VERSION:   1.0 * * HISTORY: *            1.0- 1 SS     9-Jul-2003 Created it was * * -- *//*************************************************************************** *                Definitions of channel-over-TCP                          *  ***************************************************************************/#ifndef	_TCP_H_#define	_TCP_H_#define INCLUDE_SOCKETS   /**< includes socket.h from platform include files */#include "platform.h"#include "mco.h"#include "mcoHA.h"#if !defined(_WIN32)  #include <sys/socket.h>  #include <netdb.h>  #include <netinet/in.h>  #include <netinet/tcp.h>#endif#define NW_MAX_INDEXES       32     /**< max number of indexes in index map */#ifdef CFG_TCP_SOCKET_CHANNEL#ifdef __cplusplus  extern "C" {#endif/* change this as you please *//**********************************************************************        definitions of HA endpoints **********************************************************************/  /** *  Connection parameters for IP. *  For master:   port number *  For replica:  master address: "hostname:port" * * ATTENTION! In this version of haframework the last 2 symbols of master's * logical name (port number for TCP and UDP or pipename for pipes) MUST ALWAYS BE * "00". These symbols indicate the HA instance of master and are to be replaced * by the index of current HA instance. */#define CHANNEL_NAME "TCP/IP"#define nw_MasterName      "10000"                    /**< for MASTER HA instance *///#define nw_ConnectionString "127.0.0.1:10000"        /**< for REPLICA, addres of the master to connect *///#define nw_ConnectionString "192.168.255.1:10000"//#define nw_ConnectionString "192.168.1.210:10000"//#define nw_ConnectionString "87.248.173.239:10000"#define nw_DefaultPort     "10000"/** *****************************************************************\n        definitions of HA timeouts **********************************************************************//**  Master/replica timeouts. These parameters *  are passed to the mco_HA_attach_replica() & mco_HA_attach_master() */#define TM_ATTACH_REPLICA    1000*10  /**< time to establish the initial connection and the initial */                                      /**< databases synchronization          */#define TM_DETACH_REPLICA    1000*10  /**< time to disconnect a replica from the master */#define TM_MASTER_COMMIT     1000*4   /**< total commit time (master) */#define TM_REPLICA_COMMIT    1000*4   /**< total database update time at the replica side */                                      /**< "replica commit" */#define TM_WAIT_FOR_DATA     1000*8   /**< amount of time a replica waits for the next transaction. */#define TM_SYNCH	     1000*10  /**< amount of time a replica waits for the synchronization//					   of the 2-nd phase of commit */////#define RECONNECTION_DELAY    300     /**< delay for randomizing replica's acces to master */#define TM_CONNECTION_TIMEOUT 1000*5  /**< connection timeout from peplica side */#define TM_ACCEPT_TIMEOUT     1000*60 /**< accepting connection timeout from master side */#define TM_INFINITE       -1 /**< also used if the parameter is irrelevant *//* local TCP address:port for the cancel point */#define	CANCELPOINT_ADDR	"127.0.0.1:9990" // for replica#define	CANCELPOINT_PORT	"9990"           // for master#ifndef _WIN32    typedef int                SOCKET;    typedef struct sockaddr_in SOCKADDR_IN;    typedef struct sockaddr *  LPSOCKADDR;    typedef struct timeval     TIMEVAL;#endif#define TM_CONN_MASTER      1000*1000   /**< master connection timeout */#define SEND_TIME           50          /**< send-one-byte time (us) for calculating send-block time */#define MIN_SEND_TIME       100*1000    /**< minimal guaranteed send-block time (ms) */#define MAX_DATALENGTH      32767       /**< max limit of sent data block size */#define NW_MAX_NAMELENGTH   64          /**< max length of host name *//**\struct tcp_nw_channel_   wrapper on mco_channel_t */typedef struct tcp_nw_channel_{  mco_channel_t   mco_channel;  uint2           status;         /**< internal channel status */  SOCKET          socket;         /**< socket used by channel */#ifndef _WIN32  SOCKET          cancel_socket;  /**< socket for cancelling the IO */#endif  SOCKADDR_IN     sin;            /**< socket address structure, keeps port & address                                        of the connection */  void *          db;             /**< database handle, is used in mco_nw_close() */  int2            index;          /**< internal channel index, is used                                     by the communication protocol */#ifdef _WIN32  HANDLE          event;  HANDLE          event1;#endif} nw_channel_t, *nw_channel_h;/**\struct tcp_conn_msg_ * channel-over-TCP connect message */typedef struct tcp_conn_msg_ {  uint2        index;}conn_msg_t, *conn_msg_h;#ifdef __cplusplus  }#endif#endif //!CFG_TCP_SOCKET_CHANNEL#endif	//!_TCP_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -