Ticket #2885: connect.patch

File connect.patch, 1.1 KB (added by bert@…, 17 years ago)

Patch for the mentioned problem/missing feature

  • libs/libmyth/mythsocket.cpp

     
    66#include "mythsocket.h"
    77#include <sys/select.h>
    88#include <cassert>
     9#include <netdb.h>
     10#include <arpa/inet.h>
    911
    1012#define SLOC(a) QString("MythSocket(%1:%2): ").arg((unsigned long)a, 0, 16)\
    1113                    .arg(a->socket())
     
    577579 */
    578580bool MythSocket::connect(const QString &host, Q_UINT16 port)
    579581{
     582    VERBOSE(VB_GENERAL, "Entering connect with host");
     583    struct hostent *he;
     584    in_addr * inaddr;
    580585    QHostAddress hadr;
    581     hadr.setAddress(host);
     586    if (hadr.setAddress(host))
     587        VERBOSE(VB_GENERAL, QString("Hostname was address %1: %2").arg(host).arg(hadr.toString()));
     588    else
     589    {
     590       he = gethostbyname(host.ascii());
     591       inaddr=(in_addr *)he->h_addr_list[0];
     592       hadr.setAddress(inet_ntoa(* inaddr));
     593       VERBOSE(VB_GENERAL, QString("Found IP address for host %1: %2").arg(host).arg(hadr.toString()));
     594    }
    582595    return MythSocket::connect(hadr, port);
    583596}
    584597