📄 30800e501db9001c1ebacfc9fc0bb330
字号:
#ifndef _NETSOCKET_H_
#define _NETSOCKET_H_
#define TRUE 1
#define FALSE 0
#define MIN(a,b) ((a) < (b) ? (a) : (b))
typedef int Bool;
#define IMAGE_SIZE 76800 /*image size*/
#define NET_RX_BUF_SIZE 1024 /* Receive buffer size */
#define NET_TX_BUF_SIZE 10240 /* Transmission buffer size */
#define NET_KEEP_ALIVE_COUNT 20
#define NET_KEEP_ALIVE_TIME 1000 /* TCP connection keep-alive time (ms) */
#define NET_PORT 1000 /* TCP port number to listen on */
#define MAX_NUM_LINK 5 /* Maximum concurrent connections */
/*
*Client Socket
*/
typedef struct ConnSocket
{
enum { READY, PROCESS, DATA, COMPLETE, RESET, CLOSE } state;
enum { UNKNOWN=0, GET, POST } action;
enum { COUNTED=0,CHUNKED,UNKNOWN_ENC } rx_encoding;
int fd; /* Socket descriptor */
int close; /* Close the connection after we're done? */
int keep_alive_count; /* No. of files tx'd in single connection */
int file_length; /* Length of the current file being sent */
int data_sent; /* Number of bytes already sent */
alt_u32 activity_time; /* Time of last activity */
alt_u8* rx_rd_pos; /* position we've read up to */
alt_u8* rx_wr_pos; /* position we've written up to */
alt_u8* rx_buffer; /* pointer to global RX buffer */
alt_u8* tx_buffer; /* pointer to global TX buffer */
}ConnSocket;
/*
* Linker list
*/
typedef struct ConnList
{
ConnSocket conn;
int iPosition;
struct ConnList* next;
}ConnList;
ConnSocket* AddClientSocket(ConnList* *pHead);
void DelClientSocket(ConnList* *pHead,int iPos);
ConnList* NewClientSocket();
void RestClientSocket(ConnSocket* pConn);
void ManageClientSocket(ConnList* *pHead,ConnSocket* pConn,int iPos);
int AcceptClientRequest(int listen_socket, ConnList* *pHead);
int TransData(ConnSocket *pConn);
#endif //_NETSOCKET_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -