* Fixed retrieving the port from IPv6 addresses; ie. we now support the
"[addr]:port" notation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40449 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, Axel Dörfler, [email protected].
|
* Copyright 2010-2011, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -15,7 +15,12 @@
|
|||||||
static bool
|
static bool
|
||||||
strip_port(BString& host, BString& port)
|
strip_port(BString& host, BString& port)
|
||||||
{
|
{
|
||||||
int32 separator = host.FindFirst(':');
|
int32 first = host.FindFirst(':');
|
||||||
|
int32 separator = host.FindLast(':');
|
||||||
|
if (separator != first
|
||||||
|
&& (separator == 0 || host.ByteAt(separator - 1) != ']'))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (separator != -1) {
|
if (separator != -1) {
|
||||||
// looks like there is a port
|
// looks like there is a port
|
||||||
host.CopyInto(port, separator + 1, -1);
|
host.CopyInto(port, separator + 1, -1);
|
||||||
@@ -160,7 +165,7 @@ BNetworkAddressResolver::SetTo(int family, const char* host,
|
|||||||
portString.Length() != 0 ? portString.String() : NULL, &hint, &fInfo);
|
portString.Length() != 0 ? portString.String() : NULL, &hint, &fInfo);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
return fStatus = B_OK;
|
return fStatus = B_OK;
|
||||||
|
|
||||||
// Map errors
|
// Map errors
|
||||||
// TODO: improve error reporting, maybe add specific error codes?
|
// TODO: improve error reporting, maybe add specific error codes?
|
||||||
|
|
||||||
@@ -184,12 +189,12 @@ BNetworkAddressResolver::SetTo(int family, const char* host,
|
|||||||
case EAI_MEMORY:
|
case EAI_MEMORY:
|
||||||
fStatus = B_NO_MEMORY;
|
fStatus = B_NO_MEMORY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EAI_AGAIN:
|
case EAI_AGAIN:
|
||||||
// TODO: better error code to denote temporary failure?
|
// TODO: better error code to denote temporary failure?
|
||||||
fStatus = B_TIMED_OUT;
|
fStatus = B_TIMED_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fStatus = B_ERROR;
|
fStatus = B_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user