AP_HAL: added destructor for Socket

This commit is contained in:
Staroselskii Georgii 2015-06-12 00:48:24 +03:00 committed by Andrew Tridgell
parent 4411c1fed4
commit 1a588263e4
2 changed files with 9 additions and 0 deletions

View File

@ -33,6 +33,13 @@ datagram(_datagram)
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
}
SocketAPM::~SocketAPM()
{
if (::close(fd) < 0) {
perror("close");
}
}
void SocketAPM::make_sockaddr(const char *address, uint16_t port, struct sockaddr_in &sockaddr)
{
memset(&sockaddr, 0, sizeof(sockaddr));

View File

@ -34,6 +34,8 @@
class SocketAPM {
public:
SocketAPM(bool _datagram);
~SocketAPM();
bool connect(const char *address, uint16_t port);
bool bind(const char *address, uint16_t port);
void reuseaddress();