Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android: QTcpSocket issue
QtWS25 Last Chance

Android: QTcpSocket issue

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MaxL
    wrote on last edited by
    #1

    Hi everyone,

    I'm facing an issue with QTcpSocket on Android.
    My app is really simple, it does nothing but creating a QTcpSocket, connect the stateChanged signal to a lambda function and then bind it to a port.

    @
    int main( int argc, char* argv[] )
    {
    QGuiApplication app( argc, argv)
    QTcpSocket socket;
    QObject::connect(
    & socket,
    & QTcpSocket::stateChanged,
    []( QAbstractSocket::SocketState state )
    {
    qDebug() << "State changed:" << state;
    }
    if( ! socket.bind(48484) )
    {
    qDebug() << "Could not bind to port 48484";
    }
    int ret = app.exec();
    return ret;
    }
    @

    I am using Qt 5.3 for iOS and OSX while it is Qt5.3.1 for Android.
    On iOS and OSX i get the notification that the socket is in BoundState while for Android i get BoundState but right after it i get ClosingState then UnconnectedSate

    If I run this "example":http://en.wikipedia.org/wiki/Berkeley_sockets of server/client it seems to work.

    Does anyone ever had this issue ?
    Thanks :)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      topse
      wrote on last edited by
      #2

      Did you set the "Network-Access-Rights" to your application? I think that needs to be done in some XML-file?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MaxL
        wrote on last edited by
        #3

        Indeed I have those permissions :
        @ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>@

        Whent the socket state is ClosingState or UnconnectedState the socket error is "Transport endpoint is not connected"

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved