0

I'm learning a GTK Library. Now, i'm trying use a GSocketClient. I'm connecting to a telnet-server to read some data. This code

    ...
    GInputStream* istream = g_io_stream_get_input_stream(G_IO_STREAM(scon));
    GOutputStream* ostream = g_io_stream_get_output_stream(G_IO_STREAM(scon));
    
    gsize dlen = 0;
    gchar buffer[1024];
    GError* error = NULL;
    
    while (g_input_stream_read_all(istream, buffer, 1024, &dlen, NULL, &error)) {
    
        for (int i = 0; i < dlen; i++) {
            g_print("%c", buffer[i]);
        }
        
        if (dlen < 1024) {
            break;
        }
    }
    
    if (error != NULL) {
    ....

gets first block (1024 bytes), and then it blocks until connection breaks. What me do wrong? Thanks :)

1 Answers1

0

Oh, I understood. Method g_input_stream_read_all() TRIES to read COUNT bytes until to get EOF or error. I think that it tries to read COUNT avaliables bytes. It is blocked because server-answer has size less than 2048 bytes.