Hello All!
I'm using the official ethernet shield as a client. I need to connect to 2 ports on the server (6000 and 8080). The connection to port 6000 opens, exchanges date and closes every few seconds. The connection to port 8080 is always on as long as there's data to transfer.
My question is: is it possible to have two connections opened at the same time? If so, do you see any reason on the code below for the shield not to connect to port 8080?
The code I wrote does the connection to port 6000 quite well but never seems to connect to port 8080 (I checked with net sniffer). Here are the relevant parts:
Client client(server,6000);
Client client2(server,8080);
...
void loop(){
//keep sending the IP address to the server
if (client.connect()){
delay(1000);
client.println("10.0.0.15");
delay(1000);
c = client.read();
Serial.println(c);//c will be either p (for play) or n (for noplay)
client.println("bye");
client.stop();
}
else Serial.println("Connection to port 6000 is not available!");
//the section above works well
...
if (c == 'p'){
if (!http_linked)
//this part of the code runs but I get no 8080 connection on the network sniffer
if (client2.connect()){
delay(10);
http_linked = true;
}
else Serial.println("Failed connection to streaming server!");
}
...
else {
while (client2.available()){
data = client2.read();
Wire.send(data);
}
Serial.println("I'm here 3. I get here, but still can't see any connection on port 8080...");
}
The code seems to be alright and I can only think of problems making two connections at the same time to different ports braking its execution...
Please let me know if you have any idea of what might be happening ![]()
Many TIA,
RA