返回端口号

This commit is contained in:
xiongziliang 2018-02-28 10:58:36 +08:00
parent fe4da29fb1
commit d9dea060d3
2 changed files with 18 additions and 18 deletions

View File

@ -79,38 +79,38 @@ API_EXPORT void API_CALL setGlobalOptionString(const char *key,const char *val){
} }
mINI::Instance()[key] = val; mINI::Instance()[key] = val;
} }
API_EXPORT int API_CALL initHttpServer(unsigned short port){ API_EXPORT unsigned short API_CALL initHttpServer(unsigned short port){
s_pHttpSrv.reset(new TcpServer()); s_pHttpSrv.reset(new TcpServer());
try { try {
s_pHttpSrv->start<HttpSession>(port); s_pHttpSrv->start<HttpSession>(port);
return 0; return s_pHttpSrv->getPort();
} catch (std::exception &ex) { } catch (std::exception &ex) {
s_pHttpSrv.reset(); s_pHttpSrv.reset();
WarnL << ex.what(); WarnL << ex.what();
return -1; return 0;
} }
} }
API_EXPORT int API_CALL initRtspServer(unsigned short port) { API_EXPORT unsigned short API_CALL initRtspServer(unsigned short port) {
s_pRtspSrv.reset(new TcpServer()); s_pRtspSrv.reset(new TcpServer());
try { try {
s_pRtspSrv->start<RtspSession>(port); s_pRtspSrv->start<RtspSession>(port);
return 0; return s_pRtspSrv->getPort();
} catch (std::exception &ex) { } catch (std::exception &ex) {
s_pRtspSrv.reset(); s_pRtspSrv.reset();
WarnL << ex.what(); WarnL << ex.what();
return -1; return 0;
} }
} }
API_EXPORT int API_CALL initRtmpServer(unsigned short port) { API_EXPORT unsigned short API_CALL initRtmpServer(unsigned short port) {
s_pRtmpSrv.reset(new TcpServer()); s_pRtmpSrv.reset(new TcpServer());
try { try {
s_pRtmpSrv->start<RtmpSession>(port); s_pRtmpSrv->start<RtmpSession>(port);
return 0; return s_pRtmpSrv->getPort();
} catch (std::exception &ex) { } catch (std::exception &ex) {
s_pRtmpSrv.reset(); s_pRtmpSrv.reset();
WarnL << ex.what(); WarnL << ex.what();
return -1; return 0;
} }
} }

View File

@ -56,24 +56,24 @@ API_EXPORT void API_CALL setGlobalOptionString(const char *key,const char *val);
/* /*
* :Http服务器 * :Http服务器
* :port:htt监听端口80 * :port:htt监听端口800
* :0:;-1: * :0:,0:
*/ */
API_EXPORT int API_CALL initHttpServer(unsigned short port); API_EXPORT unsigned short API_CALL initHttpServer(unsigned short port);
/* /*
* :RTSP服务器 * :RTSP服务器
* :port:rtsp监听端口554 * :port:rtsp监听端口5540
* :0:;-1: * :0:,0:
*/ */
API_EXPORT int API_CALL initRtspServer(unsigned short port); API_EXPORT unsigned short API_CALL initRtspServer(unsigned short port);
/* /*
* :RTMP服务器 * :RTMP服务器
* :port:rtmp监听端口1935 * :port:rtmp监听端口19350
* :0:;-1: * :0:,0:
*/ */
API_EXPORT int API_CALL initRtmpServer(unsigned short port); API_EXPORT unsigned short API_CALL initRtmpServer(unsigned short port);
/////////////////////////日志//////////////////////////////// /////////////////////////日志////////////////////////////////