Pages: [1]   Go Down
Author Topic: Connecting to more than 1 url.  (Read 530 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the problem. I have a sketch written with Ver 0021. I can't move it to Ver 1 because it uses several 1-wire libraries that have not been updated. It reads 1-wire weather data and also gets local rss weather feeds from Yahoo. This all works great. What I want to do now is connect to another web site ( PushingBox.com) and send a notification AFTER disconnecting from Yahoo. Does anyone know if this is possible. So far I haven't been able to do it. I don't think the old version of the Ethernet library will allow this.

Thanks,
Bill
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 115
Posts: 5377
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have v0021, but I do have v0022. Hopefully they are close enough. Declare two instances of Client. Just a rough example code snippet here:
Code:
byte server[] = { 1,2,3,4 };
byte server2[] = { 2,3,4,5 };

Client client(server, 80);
Client client2(server2, 80);

  // then in your code:
  // connect to first server
  if (client.connect()) {
    Serial.println("connected server1");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  }
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection server1 failed");
  }

  // connect to second server
  if (client2.connect()) {
    Serial.println("connected server2");
    // Make a HTTP request:
    client2.println("GET /search?q=arduino HTTP/1.0");
    client2.println();
  }
  else {
    // if you didn't get a connection to the server2:
    Serial.println("connection server 2 failed");
  }
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


When you are done with the connection you should call client.stop() and client2.stop();
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys. It works perfectly!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My Problem: I ask with a sketch about the coordinates Latitude and a second sketch about the road maps and location. Now would be one of these two sketches made ​​(2 different server IPs and URLs), can someone help me there? The goal is to display updated every 10 minutes by road and the location on the LCD which depends on the Arduino Mega + Eth + LCD. The sketches are attached. Thank you ...

* Google_Latitude_abfragen.ino (2.51 KB - downloaded 1 times.)
* Google_Maps_abfragen.ino (2.23 KB - downloaded 1 times.)
Logged

Pages: [1]   Go Up
Jump to: