Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. server-client to SQLite please help
Forum Updated to NodeBB v4.3 + New Features

server-client to SQLite please help

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 405 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    adampeter
    wrote on 29 Jun 2019, 10:44 last edited by adampeter
    #1

    Hello
    I'm trying to make server-client to SQLite db

    Server: connects to the db and start QTCPServer

    Client: sends and receives query's via QTCPSocket

    The data that will be sent over the network will be in json format

    MyServer class : only listen to the new incoming connictions and when it do it opens new thread

    MyClient class: only make a static QTcpSocket and connect it to the server

    MyQuery class: sends the query's to the MyClient::socket->write()

    The problem is that i don't i know how much the query will take time to be executed and sent over the network so i can make socket->waitReadyread(time here) also if i made it a big period it will take too much time to execute a single query

    And if i made it with slot readyread() i don't know which myQuery object sent the query to the server

    So is there is any body here can help me with that

    1 Reply Last reply
    0
    • A Offline
      A Offline
      arsinte_andrei
      wrote on 29 Jun 2019, 12:44 last edited by arsinte_andrei
      #2

      at your problem, I'll use tcpSocket::readyread()
      NOw the problems appear in your communication between your client and server. how do you communicate - keep in mind that using the TCP/Ip is a medium level of communication (low level is IP) you have to implement a hi level of protocol like HTML or FTP or IMAP and so on...
      what you need is:

      • to know that the user is a legit user
      • to verify the user with username and password
        -to make sure that all data has been received correctly

      when you make sure that the data has been transmitted correctly there are many options like CRC calculation or byte length and so on,...
      you can send something like: [byteLengts][data]
      [data] can be: [querryname] [ querry]
      so the client is sending
      [10][[querry1] [addToDatabase(field1, field1,fiel3)]]
      server response
      [3][[querry1] [ok]]

      client is sending:
      [5][[querry2] [select(tableName, fieldname=test)]
      server respond
      [400][[querry2][(record1 (field1, fiel2,field3) record2(fiel1,fiel2,fiel3).......)]]
      hope this help

      1 Reply Last reply
      0
      • A Offline
        A Offline
        arsinte_andrei
        wrote on 29 Jun 2019, 13:01 last edited by
        #3

        oh, I've forgotten to tell you that on the server you just have to keep track of the client and the query that he sent and then you just reply back with that answer...

        answwerData processMySqlquerry(answerData clientRequest){
        //answerData can be a struct or a QMap or... whatever you want a class...
        //so you proccess the class/struct/qmap data from it
        if clientRequest.querry = select then
        return select from database-and make it back as answerData
        if  clientRequest.querry = Add then
        return add to database-and make it back as answerData
        //keep in mind that is answer data you have also a field called answerData.querryName witch has to be unique for all the communications between the client and server
        }
        
        A 1 Reply Last reply 29 Jun 2019, 13:16
        0
        • A arsinte_andrei
          29 Jun 2019, 13:01

          oh, I've forgotten to tell you that on the server you just have to keep track of the client and the query that he sent and then you just reply back with that answer...

          answwerData processMySqlquerry(answerData clientRequest){
          //answerData can be a struct or a QMap or... whatever you want a class...
          //so you proccess the class/struct/qmap data from it
          if clientRequest.querry = select then
          return select from database-and make it back as answerData
          if  clientRequest.querry = Add then
          return add to database-and make it back as answerData
          //keep in mind that is answer data you have also a field called answerData.querryName witch has to be unique for all the communications between the client and server
          }
          
          A Offline
          A Offline
          adampeter
          wrote on 29 Jun 2019, 13:16 last edited by
          #4

          @arsinte_andrei ok thank you for the idea i will try to code and i faced any problems i will back

          1 Reply Last reply
          0

          1/4

          29 Jun 2019, 10:44

          • Login

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