Running TCP/UDP Server & Client at the same time - Feasible?

Hi,
So I want the Spark to run as a server most of the time, and become a client once in a while to GET a URL. But in my current implementation it runs as a Server fine but it seems to fail when trying to be a Client and GET a URL. The same Client code seems to work fine in an independent program.

TCPServer server = TCPServer(8080);
TCPClient client;
byte serverIP[] = { 10, 10, 10, 10 };

void setup(){
    Serial.begin(9600);
    server.begin();    
    delay(1000);
     
    if (client.connect(serverIP, 8084)) {
        client.println("GET /hello HTTP1.1");  // NOT WORKING
    }
}

void loop(){
    TCPClient Sparkclient = server.available();
    if(Sparkclient == true){
        <Do Something>
    }
}
  • Is it feasible to have the Spark be a Server and a Client on the same program?
  • If so, then am I doing something wrong and is there a proper way to do it?
  • Can the same be done for UDP Server & Client [Creating a UDP port, listening and sending packets]?
  • Can I have a UDP Server & Client and a TCP Server & Client all running on one spark at the same time???

I’ll update my question when I get answers and clarity. Thanks!