📄 serverfun.h
字号:
/*
*
* Copyright (C) 2003 Xiangbin Lee <honeycombs@sina.com> <honeycombs@263.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation.
*/
#ifndef _SERVER_FUN_H_
#define _SERVER_FUN_H_
#include "ache.h"
#include "datetime.h"
#include "protocal.h"
#include "netdrv.h"
#include "netspy.h"
#include "packet.h"
/* **********************************************************************
----------- Socket Communication
********************************************************************** */
/* Globle Veriable for Communication processor */
typedef struct _REQList {
/* added by leexb for process */
#ifdef GTK_INCLUDE
pthread_t pid;
#else
int pid; /* Socket Thread id */
#endif
time_t _ctime; /* create time */
time_t _vtime; /* last visit time */
char ClientAddr[16]; // Client's IP (get from inet_ntoa() )
struct sockaddr_in addr_client; // Client's socket address: invoked by accept()
SOCKET sd_accept ; //Socket accept handle
int ifprocessrun;
unsigned long rcount; /* flow */
unsigned long rpcount; /* flow */
unsigned long wcount; /* flow */
unsigned long wpcount; /* flow */
/* added by leexb for ache buffer */
int recvlen, res,error;
unsigned char request[MAXRECLEN] ;
}REQLIST;
/* client data cache , functions list */
typedef struct _ClientDataInfo
{
unsigned long nID;
unsigned long dtime;
unsigned short length;
unsigned char data[1];
}ClientDataInfo, *LPClientDataInfo;
typedef struct _LinkClientInfo
{
REQLIST *lpuser;
WINPRO_ACHE DataAche;
}LinkClientInfo, *LPLinkClientInfo;
LinkClientInfo *GetConnectClient(REQLIST *lpusr);
LinkClientInfo *CheckConnectClient(REQLIST *lpusr);
int GetDisconnectClient(REQLIST *lpusr);
ClientDataInfo *InsertDataToClient(
REQLIST *lpusr,
unsigned char *dest,
unsigned short lenth);
int GetClientDataCount(REQLIST *lpusr);
ClientDataInfo *GetClientFirstData(REQLIST *lpusr);
ClientDataInfo *GetClientNextData(REQLIST *lpusr);
/* server conection data cache , functions list */
void ResetSrvclientData(REQLIST *lpclient);
REQLIST *MallocSocketUser(unsigned long wnd);
int FreeSocketUser( unsigned long wnd);
int FreeAllSocketUser(void);
unsigned long GetSocketUsercount(void);
unsigned long CheckSocketUser(REQLIST *lpuser);
REQLIST *GetSocketUser(unsigned long wnd);
REQLIST *GetNextSocketUser(void);
char *Server_GetHost(void);
char *Server_GetHostname(void);
void Server_SetPort(unsigned short port);
unsigned short Server_GetPort(void);
int Server_Open(void); /* Open server's socket port & create accept thread. */
int Server_Close(void) ; /* Close server's socket port */
int Server_SendToClient(REQLIST *lpuser, unsigned char *dest, int sendlen);
int Server_RemoveClient(REQLIST *lpuser);
void Server_SetClientPro(
void (*OnDebugMessage)( char *, ... ),
int (*OnClientConnected)(REQLIST *),
int (*OnClientDisconnected)(REQLIST *),
int (*OnRequestPro)(REQLIST *,unsigned char *,int),
int (*OnClientSend)(REQLIST *,unsigned char *,int)
);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -