1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

use the right int type for port.

This commit is contained in:
winlin 2015-09-24 18:33:07 +08:00
parent 1c7d5f1852
commit d8f18aee37
20 changed files with 105 additions and 149 deletions

View file

@ -180,13 +180,27 @@ string srs_dns_resolve(string host)
void srs_parse_hostport(const string& hostport, string& host, int& port)
{
host = hostport;
size_t pos = hostport.find(":");
if (pos != std::string::npos) {
string p = hostport.substr(pos + 1);
host = hostport.substr(0, pos);
port = ::atoi(p.c_str());
} else {
host = hostport;
}
}
void srs_parse_endpoint(string hostport, string& ip, int& port)
{
ip = "0.0.0.0";
size_t pos = string::npos;
if ((pos = hostport.find(":")) != string::npos) {
ip = hostport.substr(0, pos);
string sport = hostport.substr(pos + 1);
port = ::atoi(sport.c_str());
} else {
port = ::atoi(hostport.c_str());
}
}
@ -206,6 +220,10 @@ string srs_float2str(double value)
return tmp;
}
string srs_bool2switch(bool v) {
return v? "on" : "off";
}
bool srs_is_little_endian()
{
// convert to network(big-endian) order, if not equals,