2017-04-21 10:43:26 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tencent is pleased to support the open source community by making MSEC available.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the GNU General Public License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License. You may
|
|
|
|
|
* obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* https://opensource.org/licenses/GPL-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software distributed under the
|
|
|
|
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
|
|
|
* either express or implied. See the License for the specific language governing permissions
|
|
|
|
|
* and limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @filename mt_api.h
|
|
|
|
|
* @info <EFBFBD>̷߳<EFBFBD>װϵͳapi, ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>API<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __MT_API_H__
|
|
|
|
|
#define __MT_API_H__
|
|
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
|
namespace NS_MICRO_THREAD {
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7>ӿ<EFBFBD> */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ڵ<EFBFBD>socket<EFBFBD>շ<EFBFBD><EFBFBD>ӿ<EFBFBD>, <EFBFBD><EFBFBD>socket<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* [ע<EFBFBD><EFBFBD>] UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff, <EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD>static<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD><EFBFBD>Ҫ]
|
|
|
|
|
* @param dst -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param pkg -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rcv_buf -<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff
|
|
|
|
|
* @param buf_size -modify-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD><EFBFBD>С, <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ, <EFBFBD><EFBFBD>ΪӦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout -<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @return 0 <EFBFBD>ɹ<EFBFBD>, -1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>socketʧ<EFBFBD><EFBFBD>, -2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, <EFBFBD>ɴ<EFBFBD>ӡerrno
|
|
|
|
|
*/
|
|
|
|
|
int mt_udpsendrcv(struct sockaddr_in* dst, void* pkg, int len, void* rcv_buf, int& buf_size, int timeout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: TCP<43><50><EFBFBD>ӳ<EFBFBD><D3B3>շ<EFBFBD><D5B7>ӿ<EFBFBD> */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD>滺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len <EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>յij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 ʵ<EFBFBD>ʵı<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>; 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; <0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
|
|
|
|
*/
|
|
|
|
|
typedef int (*MtFuncTcpMsgLen)(void* buf, int len);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳصķ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP/PORT<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* [ע<EFBFBD><EFBFBD>] tcp<EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><EFBFBD><EFBFBD>buff, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> [<EFBFBD><EFBFBD>Ҫ]
|
|
|
|
|
* @param dst -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param pkg -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rcv_buf -<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff
|
|
|
|
|
* @param buf_size -modify-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD><EFBFBD>С, <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ, <EFBFBD><EFBFBD>ΪӦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout -<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @param check_func -<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﺯ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return 0 <EFBFBD>ɹ<EFBFBD>, -1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>socketʧ<EFBFBD><EFBFBD>, -2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>,
|
|
|
|
|
* -4 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -5 <EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -6 <EFBFBD><EFBFBD><EFBFBD>տռ䲻<EFBFBD><EFBFBD>, -7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>-10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
*/
|
|
|
|
|
int mt_tcpsendrcv(struct sockaddr_in* dst, void* pkg, int len, void* rcv_buf, int& buf_size,
|
|
|
|
|
int timeout, MtFuncTcpMsgLen chek_func);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum MT_TCP_CONN_TYPE
|
|
|
|
|
{
|
|
|
|
|
MT_TCP_SHORT = 1, /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
MT_TCP_LONG = 2, /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
MT_TCP_SHORT_SNDONLY = 3, /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>
|
|
|
|
|
MT_TCP_LONG_SNDONLY = 4, /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>
|
|
|
|
|
MT_TCP_BUTT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD>շ<EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* [ע<EFBFBD><EFBFBD>] tcp<EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><EFBFBD><EFBFBD>buff, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> [<EFBFBD><EFBFBD>Ҫ]
|
|
|
|
|
* @param dst -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param pkg -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rcv_buf -<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪNULL
|
|
|
|
|
* @param buf_size -modify-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD><EFBFBD>С, <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ, <EFBFBD><EFBFBD>ΪӦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪNULL
|
|
|
|
|
* @param timeout -<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @param check_func -<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﺯ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param type - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* MT_TCP_SHORT: һ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
* MT_TCP_LONG : һ<EFBFBD><EFBFBD>һ<EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
* MT_TCP_LONG_SNDONLY : ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
* MT_TCP_SHORT_SNDONLY: ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
|
|
|
|
* @return 0 <EFBFBD>ɹ<EFBFBD>, -1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>socketʧ<EFBFBD><EFBFBD>, -2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>,
|
|
|
|
|
* -4 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -5 <EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>, -6 <EFBFBD><EFBFBD><EFBFBD>տռ䲻<EFBFBD><EFBFBD>, -7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, -10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
*/
|
|
|
|
|
int mt_tcpsendrcv_ex(struct sockaddr_in* dst, void* pkg, int len, void* rcv_buf, int* buf_size,
|
|
|
|
|
int timeout, MtFuncTcpMsgLen func, MT_TCP_CONN_TYPE type = MT_TCP_LONG);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<EFBFBD><EFB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FBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buf<EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD><EFBFBD>ݸ<EFBFBD>ֵrealloc buf<EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buf<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD>realloc buf<EFBFBD><EFBFBD>buf<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵС<EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾҵ<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
typedef int (*MtFuncTcpMsgChecker)(void* buf, int len, bool closed, void* msg_ctx, bool &msg_len_detected);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD>շ<EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* [ע<EFBFBD><EFBFBD>] tcp<EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><EFBFBD><EFBFBD>buff, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> [<EFBFBD><EFBFBD>Ҫ]
|
|
|
|
|
* @param dst -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param pkg -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rcv_buf -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> keep_rcv_buf<EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫmalloc<EFBFBD><EFBFBD><EFBFBD>ڴ档void* rcv_buf=NULL: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param recv_pkg_size -<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><EFBFBD>ȡ<EFBFBD>
|
|
|
|
|
* @param timeout -<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @param check_func -<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﺯ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param msg_ctx -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* @param type - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* MT_TCP_SHORT: һ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFB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int& recv_pkg_size,
|
|
|
|
|
int timeout, MtFuncTcpMsgChecker check_func, void* msg_ctx=NULL,
|
|
|
|
|
MT_TCP_CONN_TYPE type = MT_TCP_LONG, bool keep_rcv_buf=false);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳصķ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP/PORT<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* [ע<EFBFBD><EFBFBD>] tcp<EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><EFBFBD><EFBFBD>buff, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> [<EFBFBD><EFBFBD>Ҫ]
|
|
|
|
|
* @param dst -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param pkg -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>İ<EFBFBD><EFBFBD>峤<EFBFBD><EFBFBD>
|
|
|
|
|
* @param rcv_buf -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> keep_rcv_buf<EFBFBD><EFBFBD>
|
|
|
|
|
* @param recv_pkg_size -<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buff<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><EFBFBD>ȡ<EFBFBD>
|
|
|
|
|
* @param timeout -<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @param check_func -<EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﺯ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param msg_ctx -<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param keep_rcv_buf -true,<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rcv_buf<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBF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D><EFBFBD>, -7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, -10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
*/
|
|
|
|
|
int mt_tcpsendrcv(struct sockaddr_in* dst, void* pkg, int len, void*& rcv_buf, int& recv_pkg_size,
|
|
|
|
|
int timeout, MtFuncTcpMsgChecker check_func, void* msg_ctx=NULL, bool keep_rcv_buf=false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: <>߳<EFBFBD>Task<73><6B>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ģ<EFBFBD>ͽӿڶ<D3BF><DAB6><EFBFBD> */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
class IMtTask
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return 0 -<EFBFBD>ɹ<EFBFBD>, < 0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual int Process() { return -1; };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>taskִ<EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @info <EFBFBD><EFBFBD>Process<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
*/
|
|
|
|
|
void SetResult(int rc)
|
|
|
|
|
{
|
|
|
|
|
_result = rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ȡtaskִ<EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @info <EFBFBD><EFBFBD>Process<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
*/
|
|
|
|
|
int GetResult(void)
|
|
|
|
|
{
|
|
|
|
|
return _result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>task<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void SetTaskType(int type)
|
|
|
|
|
{
|
|
|
|
|
_type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ȡtask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @info <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>task<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ø<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>ͬ<EFBFBD><EFBFBD>task<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return <EFBFBD><EFBFBD>ȡtask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int GetTaskType(void)
|
|
|
|
|
{
|
|
|
|
|
return _type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
IMtTask() {};
|
|
|
|
|
virtual ~IMtTask() {};
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
int _type; // task<73><6B><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>task<73><6B>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD>ת<EFBFBD><D7AA>
|
|
|
|
|
int _result; // taskִ<6B>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Process<73><73><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef vector<IMtTask*> IMtTaskList;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>·IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, Task-fork-waitģʽ<EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
* @param req_list -task list <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>api<EFBFBD><EFBFBD>task<EFBFBD>б<EFBFBD>
|
|
|
|
|
* @return 0 <EFBFBD>ɹ<EFBFBD>, -1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_exec_all_task(IMtTaskList& req_list);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: <>̷߳<DFB3>װϵͳ<CFB5>ӿ<EFBFBD> */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sleep<EFBFBD>ӿ<EFBFBD>, <EFBFBD><EFBFBD>λms
|
|
|
|
|
* @info ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>CPUʱʹ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void mt_sleep(int ms);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̻߳<EFBFBD>ȡϵͳʱ<EFBFBD>䣬<EFBFBD><EFBFBD>λms
|
|
|
|
|
*/
|
|
|
|
|
unsigned long long mt_time_ms(void);
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: <>߳<EFBFBD><DFB3>û<EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD><EFBFBD>ݽӿ<DDBD> */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰIMtMsg<EFBFBD><EFBFBD>˽<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @info ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>Ҫҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void mt_set_msg_private(void *data);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰIMtMsg<EFBFBD><EFBFBD>˽<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return ˽<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void* mt_get_msg_private();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* <>߳<EFBFBD><DFB3>û<EFBFBD><C3BB>ӿڶ<D3BF><DAB6><EFBFBD>: <>̷߳<DFB3>װϵͳ<CFB5>ӿ<EFBFBD>(<28><><EFBFBD>Ƽ<EFBFBD>ʹ<EFBFBD><CAB9>) */
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>߳̿<EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @info ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>spp<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>
|
|
|
|
|
* ʹ<EFBFBD><EFBFBD>spp<EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD>SyncFrame<EFBFBD>Ŀ<EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return false:<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> true:<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
2017-08-08 14:36:49 +00:00
|
|
|
|
bool mt_init_frame(int argc=0, char * const argv[]=NULL);
|
2017-04-21 10:43:26 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶߳<EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @info <EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ĭ<EFBFBD>ϴ<EFBFBD>СΪ128K
|
|
|
|
|
*/
|
|
|
|
|
void mt_set_stack_size(unsigned int bytes);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> recvfrom
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param len <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param from <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param fromlen <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ַ<EFBFBD>Ľṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_recvfrom(int fd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> sendto
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param msg <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param len <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param to Ŀ<EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param tolen Ŀ<EFBFBD>ĵ<EFBFBD>ַ<EFBFBD>Ľṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_sendto(int fd, const void *msg, int len, int flags, const struct sockaddr *to, int tolen, int timeout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> connect
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param addr ָ<EFBFBD><EFBFBD>server<EFBFBD><EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
* @param addrlen <EFBFBD><EFBFBD>ַ<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_connect(int fd, const struct sockaddr *addr, int addrlen, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> accept
|
|
|
|
|
* @param fd <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param addr <EFBFBD>ͻ<EFBFBD><EFBFBD>˵<EFBFBD>ַ
|
|
|
|
|
* @param addrlen <EFBFBD><EFBFBD>ַ<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >=0 accept<EFBFBD><EFBFBD>socket<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_accept(int fd, struct sockaddr *addr, socklen_t *addrlen, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> read
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param nbyte <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ssize_t mt_read(int fd, void *buf, size_t nbyte, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> write
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param nbyte <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ssize_t mt_write(int fd, const void *buf, size_t nbyte, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> recv
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param len <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ssize_t mt_recv(int fd, void *buf, int len, int flags, int timeout);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̰߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD> send
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param nbyte <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
ssize_t mt_send(int fd, const void *buf, size_t nbyte, int flags, int timeout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>̵߳ȴ<EFBFBD>epoll<EFBFBD>¼<EFBFBD><EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param fd ϵͳsocket<EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param events <EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> IN/OUT
|
|
|
|
|
* @param timeout <EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return >0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>, <0 ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int mt_wait_events(int fd, int events, int timeout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void* mt_start_thread(void* entry, void* args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|