Program is often blocked with using TPowersock



  • I use TPowersock to communicate with a remote server as following code:

    String response = "";
    try
    {
    Powersock1->Host = "*****";
    Powersock1->Port = ****;
    Powersock1->TimeOut = 50000;
    Powersock1->Connect();

    String tmp = "";
    String firstLine = "";
    int s=0;
    while (1)
    {
    tmp = Powersock1->Transaction(request);

    if (s == 0)
    {
    firstLine = tmp;
    }
    if (tmp.AnsiCompareIC(firstLine) == 0 && s != 0)
    break;
    xmlResp->Add(tmp);
    response = response + tmp;
    s++;
    }
    Powersock1->Disconnect();
    } catch (...)
    {
    //Exception handeling
    }
    return response;

    The variable "tmp" gets response from the server line by line with the "method Transaction(String)". As soon as "tmp" gets a same response as the first one, the loop will be terminated. (I use this way for loop because I don't find any methods or attributes to show length/count of the response)
    My problem is that the program is always blocked if the response is too large (with too many lines) e.g the program cannot carry on if the response is large than 3 KB (100 lines). I suppose that this is because the program receives responses line by line, the posibilities for some line to be blocked with internet connection will be higher if the response is too much.

    I don't know if anyone has ever met same problem as I have. Hopefully you can give me some guidance. Or do you konw if there are any other good components to communicate with a server with socket.

    Thanks


Anmelden zum Antworten