Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. client
    Log in to post

    • UNSOLVED SERVER/CLIENT cannot send and recieve data on the same socket, server close server after first attempt
      General and Desktop • server client close conecctio • • Lightshadown  

      7
      0
      Votes
      7
      Posts
      52
      Views

      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")
    • UNSOLVED Modbus TCP handle asynchronous communication
      General and Desktop • tcp modbus client asynchronous • • derlucae98  

      1
      0
      Votes
      1
      Posts
      258
      Views

      No one has replied

    • UNSOLVED QTOpcUa -- connectToEndPoint Error
      General and Desktop • client opcua • • TMJJ001  

      6
      0
      Votes
      6
      Posts
      269
      Views

      @thisisseven said in QTOpcUa -- connectToEndPoint Error: "opc.tcp://localhost:4840" https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html#connectToEndpoint https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html#usage
    • SOLVED read single byte from socket ethernet
      Mobile and Embedded • qtcpsocket server client ethernet in qt read one byte • • vishbynature  

      7
      0
      Votes
      7
      Posts
      650
      Views

      @aha_1980 ok, thanks help again. regards.
    • UNSOLVED Send and receive strings with QTcpSocket
      General and Desktop • qtcpsocket tcp server client • • Captain Matsuyo  

      6
      0
      Votes
      6
      Posts
      1957
      Views

      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"; });
    • UNSOLVED QTcpSocket state always connected
      General and Desktop • qtcpsocket client • • Gianluca86  

      23
      0
      Votes
      23
      Posts
      11305
      Views

      @puzzled_giraffe QTcpsocket have not got "connectState" setup? I think qt use long tcp connection by default.
    • UNSOLVED Parsing CSV file to construct Modbus Request Packet
      General and Desktop • modbus client packets master • • musclemania05  

      1
      0
      Votes
      1
      Posts
      701
      Views

      No one has replied

    • UNSOLVED SSL Client/Server Handshake
      General and Desktop • ssl server - client client handshake • • marlenet15  

      4
      0
      Votes
      4
      Posts
      5373
      Views

      The handshake is the process that establishes the secure connection, in Qt QSslSocket::connectToHostEncrypted and QSslSocket::startServerEncryption take care of the handshake. The "Hello Word" sent across is just normal TCP communication that could be done even without encryption (i.e. using QTcpSocket)
    • SOLVED Running Qt Example client/server not working
      General and Desktop • network qtnetwork server client • • marlenet15  

      17
      0
      Votes
      17
      Posts
      5890
      Views

      @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.
    • UNSOLVED Client-Server. Send data
      General and Desktop • c++ tcp server client • • mandruk1331  

      2
      0
      Votes
      2
      Posts
      1429
      Views

      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" ?
    • non blocking threaded tcp client
      C++ Gurus • thread tcp client • • Bremenpl  

      10
      0
      Votes
      10
      Posts
      4783
      Views

      @stereomatchingkiss Indeed, such a huge amount of connections in such a short time would rather need a thread pool, otherwise you're going to starve your system.