wifi web client connection by custom library routine: "no socket available"

Hi to all and tank you for any suggestion.

I' m trying to implement a web client connection (GET HTTP server request by wifi shield) in a library routine.

First of all..
I tried a simple code (without library help routine) to connect my wifi shield as a client to send an "http GET" request to my domain page.

This test works fine.
Excluding the whole code (with wifi LAN connection etc.) I show the (working) part of code of webclient GET HTTP request:

// variables declaration:
char server[] ="mysite.com";      // server setted as a char array, for matching with client.connect
String location = "/folder/file.php/";  // location setted as a String
String datastring = "/01/02";           // datastring, to send variables to php page.

// wifi client class declaration:
WiFiClient client;

void UpdateData() {
  if (client.connect(server, 80)) {
    link = String("GET http://" + String(server) + location + datastring + "HTTP/1.1");
    Serial.println("server answer:");
    while (client.available() && status == WL_CONNECTED) {
      char c = client.read();
    if (!client.connected()) {
    Serial.println("connection error!");

this code works fine and i can send, by command "client.println(link)" variables as:
GET http://mysite.com/folder/file.php/01/02HTTP/1.1
with a right server answer:
printed by char c = client.read() and Serial.print(c).

Now I'm trying to implement past void in a library file (.cpp) and relative header (h).

the code I used in the .cpp file is:

void CLASS::sendData(char* value4, char* value5, char* value6){
    char* serverData = value4;
    char* locationData = value5;
    char* dataString = value6;

    Serial.println("Connecting to server...");
    if (WiFiClient().connect(serverData, 80)) {
    // create link with data for server:
    // create link as a string concatenation using "strcat"
    // send link request to server:

    // wait answer from server:
    while (WiFiClient().available() && status == WL_CONNECTED) {
      char c = WiFiClient().read();
    // close client:
    // check client disconnection:
    if (!WiFiClient().connected()) {
    Serial.println("Connection Error");

The routine works by tree variables, so I call this library function by this arduino code:

// arduino code for sendData(char* value4, char* value5, char* value6) call,
// with server, location and datastring setted as char[] (array).

// declaration of Class for library
libraryClass board;

// call of sendData function in library class:
board.sendData(server, location, datastring);

Everything works, and I don't receive any compiling error..
but I receive from server:
no socket available

The error is during command: WiFiClient().connect(serverData, 80)
I think it maybe due for a wrong formatting of serverData, but I can't understand why and how to fix.

sorry for this very long post, I tried to resume.. but it's complicated..
Tank you for any suggestion.