net/SocketAddress: add method GetPort()

This commit is contained in:
Max Kellermann
2017-05-17 09:28:12 +02:00
parent 907fb257cd
commit 77c747a8fd
2 changed files with 42 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2015 Max Kellermann <max.kellermann@gmail.com>
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
#ifndef SOCKET_ADDRESS_HXX
#define SOCKET_ADDRESS_HXX
#include "Features.hxx"
#include "Compiler.h"
#include <cstddef>
@@ -92,6 +93,14 @@ public:
return GetFamily() != AF_UNSPEC;
}
#ifdef HAVE_TCP
/**
* Extract the port number. Returns 0 if not applicable.
*/
gcc_pure
unsigned GetPort() const;
#endif
gcc_pure
bool operator==(const SocketAddress other) const noexcept;