Skip to content
  • 0 Votes
    2 Posts
    109 Views
    SGaistS

    Hi and welcome to devnet,

    Quite frankly that sounds like a homework assignment.

    What do you know about http authentication ?

  • 0 Votes
    7 Posts
    306 Views
    L

    well at the end i simply sended all the data and split everything inside a list, not the best thing to do but it works, heres the code

    def servidorMk3(): host = socket.gethostname() host_port = 8000 host_ip = socket.gethostbyname(host) buffer = 1024 code_end = "<END>" code_ok = "<OK>" code_fin = "<FIN>" code_sep = "<SEP>" nombre, size, dataFile, elemt = [], [], [], [] print (f"Servidor Mk3") print (f"Ip del servidor: " + host_ip) log("Inicio del servidorMk3 " + host_ip) with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as tcp_conn: tcp_conn.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) tcp_conn.bind((host_ip, host_port)) tcp_conn.listen(1) con, adrs = tcp_conn.accept() print (f"Conecion Exitosa") log("Connecion exitosa con el server: " + adrs[0]) while True: alldata = con.recv(buffer) while True: # recibe la info en general alldata = alldata + con.recv(buffer) if code_fin.encode("utf8") in alldata: # si llega <FIN>, se acabo la lista break data = alldata.split(b'<SEP>') #separar manualmente while code_fin.encode("utf8") in data: data.remove(code_fin.encode("utf8")) for i in range(0, len(data),3): bloque = data[i:i+3] nombre.append(bloque[0].decode("utf8")) print(nombre) size.append(bloque[1].decode("utf8")) dataFile.append(bloque[2]) directorio = crear_directorio() for x in range(len(nombre)): if directorio == "<BAD>": print(" no se puede crear la ubicacion") print(type(directorio)) # revisar el tipo que regresa esta funcion¡¡¡¡ print(directorio) break else: print(f"0 .. {nombre[x]}") print(f"1 .. {size[x]}") #print (dataFile) file_name = directorio + nombre[x] # path to the file, file_size = int(size[x]) # size of file file_create = open(file_name, 'wb') # open file for writing in binary file_create.write(dataFile[x]) # writes to the file file_create.close() #close the file check = os.path.getsize(file_name) # returns the size of the file print (f"Tamaño esperado: {file_size} ... tamaño real {check} ") if check == file_size: log("archivo " + file_name + " creado, tamaño: " + str(file_size)) else: log("No se pudo crear el archivo: " + file_name) if x == len(nombre): log("Respaldo de Archivos completado") tcp_conn.close() print(f"Respaldo de archivos terminada")
  • 0 Votes
    8 Posts
    1k Views
    N

    Nevermind ! It worked !!!!!!! Thank you !!!

  • 0 Votes
    4 Posts
    1k Views
    aniketRoxyA

    Thank you @jsulm & @KroMignon !!
    :)

    Ports 0-1024 are "protected" for "known" services and By "protected", they must be used by system daemons. Thus, a regular user cannot start them.

    Solution 1:
    Run application using terminal:

    sudo \path\to\app

    Solution 2:
    Use a port above 1024
    So i changed port from 502 to 1502:

    const QUrl url = QUrl::fromUserInput("127.0.0.1:1502");

    Working now!!
    <3 Qt

  • 0 Votes
    16 Posts
    1k Views
    JKSHJ

    @ELEMENTICY said in MySQL Connection failed,but i entered correct info of server:

    I tried it,it doesnt work.
    Can you help again xD

    You need to provide details of what you tried and what errors you got. Without the details, we can't help you.

  • 0 Votes
    7 Posts
    1k Views
    V

    @aha_1980
    ok, thanks help again.
    regards.

  • 0 Votes
    6 Posts
    3k Views
    VRoninV

    QTcpSocket socMeteo;
    QTextStream texte(&socHauteur);

    These are 2 different sockets. What are you trying to do?

    It should be something like:

    auto socMeteo = new QTcpSocket(this); socMeteo->connectToHost("192.168.1.35",10001); connect(socMeteo,&QTcpSocket::connected,socMeteo,[socMeteo]()->void{ QTextStream texte(socMeteo); texte<<"Bonsoir\n"; });
  • 0 Votes
    14 Posts
    2k Views
    K

    what is your suggestion about server app design ?

    People usually refer to "server app" as "middleware" or "web application". There are tons of web frameworks and ORMs for various languages including Java and C# on "enterprise" side and scripting languages (pphp, python, perl, ruby, node.js). C++ is not really convenient language here. As for protocol, if you are not pursuing real-time data processing with lowest possible latency, it makes sense to use REST API on top of HTTP, so that on server side you have the most typical "web app" with ORM inside and REST outside, and on client side you can easily add web client if needed, and even if not, you get some additional convenience as compared to e.g. RPC over plain TCP

  • 0 Votes
    22 Posts
    4k Views
    SGaistS

    IIRC, you have QTest;:wait for that kind of stuff.

  • 0 Votes
    2 Posts
    923 Views
    Pablo J. RoginaP

    @Allerknappe should your question better suited for AWS support team? or cloud forum? It seems not related to Qt itself.
    Anyway, from little experience with a (non Qt) REST server running in AWS, in that case the server was configured with "internal" IP and then the AWS security team forwarded the proper port(s) so the solution could be available from outside.

  • 0 Votes
    4 Posts
    2k Views
    ChristianMonteroC

    @ambershark Thank you very much for your help, now it's working, it seems like I was passing the IP argument incorrectly, now I know that I have to send this parameter inside a QT function. thanks!

  • 0 Votes
    3 Posts
    2k Views
    ChristianMonteroC

    @juanki sí, de hecho al final encontre que mi error era porque la IP la tenia que mandar dentro de un método de la librería, igual gracias por tu post :)

  • 0 Votes
    9 Posts
    3k Views
    mrjjM

    @HenrikSt.
    Nice day to you too: Please mark as solved :)

  • 0 Votes
    17 Posts
    7k Views
    kshegunovK

    @marlenet15
    Hi,
    Here you can find a threaded TCP server example. You can ignore the module specific classes QDaemonApplication (think of it as QCoreApplication) and QDaemonLog you can substitute with QDebug.

    Enjoy!
    Kind regards.

  • 0 Votes
    9 Posts
    2k Views
    D

    @JonB I also thought it could be due to cache, so I ran the manager.clearConnectionCache command but that does not help.

    I also tried to find a way to force it to provide credentials but I have not found any other way to do so. But that was when I still wasn't sure that the server actually requests this, but since I now know that the server sends the www-authenticate request I know the error is in my applicaton or in qt.

    Yes, I get the QNetworkReply::AuthenticationRequiredError. So weird that I get that error and not the authenticationRequired signal.

  • 0 Votes
    4 Posts
    2k Views
    SGaistS

    Well, follow the documentation starting here. You'll find the relevant topics on how to connect to a database, run queries, use models etc.

  • Client-Server. Send data

    Unsolved General and Desktop
    2
    0 Votes
    2 Posts
    2k Views
    SGaistS

    Hi,

    You have the Fortune server and Fortune client that can serve as base to get you started. The main "detail" is that you want to exchange the sender and receiver part but the technique described there is still valid.

    Out of curiosity, how much is "large amount of data" ?

  • 0 Votes
    2 Posts
    1k Views
    D

    @Dooms said:

    sslConfiguration

    You don't seem to have actually associated the sslConfiguration object with the QSslSocket object.

    You can set the cert/key files directly on the QSslSocket if that helps simplify your code for testing...

  • 0 Votes
    1 Posts
    991 Views
    No one has replied