#ifndef _COMM_TCP_H_
#define _COMM_TCP_H_

#include "myComm.h"
#include "comm.h"

#define TCP_MAX_CONN_NUM 16

typedef struct 
{
    stru_tcp_para *p_para;
    int sockfd;
    int sock_listen_fd;
    int client_fd[TCP_MAX_CONN_NUM];

    CommDebugShow debug_show;

    comm_state_cb state_cb;
    comm_recv_cb recv_cb;
    comm_debug_show_cb debug_show_cb;

    int (*tcp_state_register)(void *p_this, comm_state_cb cb);
    int (*tcp_recv_register)(void *p_this, comm_recv_cb cb);
    int (*tcp_debug_show_register)(void *p_this, comm_debug_show_cb cb);

    int (*tcp_server_connect)(int id, void *p_this);
    int (*tcp_client_connect)(int id, void *p_this);

    int (*tcp_send)(int id, int fd, const char *tcp_type, void *p_this, const uint8_t*data, uint16_t len);

    int (*tcp_close)(int id, void *p_this);
}stru_comm_tcp;


int comm_tcp_create(stru_comm_tcp *tcp);

#endif /* _COMM_TCP_H_ */