// Use of this source code is governed by a BSD 3-Clause License // that can be found in the LICENSE file. // Author: caozhiyi (caozhiyi5@gmail.com) #ifndef INCLUDE_CPPNET_TYPE #define INCLUDE_CPPNET_TYPE #include #include #include #include "common/buffer/buffer_interface.h" namespace cppnet { // socket class CNSocket; typedef std::shared_ptr Handle; typedef std::shared_ptr BufferPtr; // call back define // param : param is setted when set typedef std::function timer_call_back; typedef std::function user_timer_call_back; // handle : handle of socket // err : error code typedef std::function connect_call_back; // handle : handle of socket // len : sended date len typedef std::function write_call_back; // handle : handle of socket // data : point to recv data buffer // len : recv data len typedef std::function read_call_back; // error code enum CPPNET_ERROR_CODE { CEC_SUCCESS = 0, // success. CEC_TIMEOUT = 1, // the event time out call back. CEC_CLOSED = 2, // remote close the socket. CEC_INVALID_HANDLE = 3, // invalid cppnet handle, can find in socket manager. CEC_FAILED = 4, // call function failed. CEC_CONNECT_BREAK = 5, // connect break. CEC_CONNECT_REFUSE = 6, // remote refuse connect or server not exist. }; } #endif