[mythtv-users] Connect to backend via hostname

Erik Jensen eriksjunk at laurelwoodart.com
Fri Feb 13 03:16:27 UTC 2009

I am currently trying to set up MythTV on a network that uses dynamically
assigned IP addresses using version 0.21-fixes-r19046.  I have no control
over the networks configuration, and thus can't give my media center a
static ip.  It does, however, have a consistent hostname.  When configuring
MythTV, I entered this hostname as the master backend ip address, hoping
that it would allow consistent access to my media center.  To my
dissapointment, it doesn't work.

I tried running "mythfrontend -v socket" on my remote front end, and
discovered that it was trying to connect to "".  Apparently, it is
not resolving the hostname.

I took a quick look at the code, and found what might be the coulprit in

bool MythSocket::connect(const QString &host, Q_UINT16 port)
    QHostAddress hadr;
    return MythSocket::connect(hadr, port);

This is called from MythContext::ConnectServer as
"serverSock->connect(hostname, port)", where hostname is the value from the
database and is, in my case, actually a hostname.

MythSocket::connect is just passing "host" directly to hadr.setAddress,
which only accepts IP addresses.

I was thinking that I could get this to work if I changed the function to
something like this:

bool MythSocket::connect(const QString &host, Q_UINT16 port)
    QHostAddress hadr;
    if (!hadr.setAddress(host))
        // Try to resolve hostname here
    return MythSocket::connect(hadr, port);

I was hoping that someone could point me into the right direction as to how
to perform the name resolution, as I have not worked with Qt before.  I took
a quick look through the docs, but all I found was QSocket::connectToHost,
which does name resolution for you.  Unfortunately, using this does not look
like a possibility here.

Any advice would be appreciated.

Thank You,
Erik Jensen

"Cats are intended to teach us that not everything in nature has a purpose."
 -- Garrison Keillor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mythtv.org/pipermail/mythtv-users/attachments/20090212/13026234/attachment.htm>

More information about the mythtv-users mailing list