极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11692|回复: 3

Arduino联网书本中的一些问题

[复制链接]
发表于 2013-7-5 22:45:33 | 显示全部楼层 |阅读模式
这个是英文书本,看到联网这块的部分,对网络不是很懂,虽然有英文解释还是有点不懂,希望谁能给我讲解下
#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168 1, 177 }; // change to a valid address for your network
byte server[] = { 64, 233, 187, 99 }; // Google
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0"); // the HTTP request
client.println();
} else {
Serial.println("connection failed");

void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c); // echo all data received to the Serial Monitor
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)

;
}
}这些是什么意思?byte ip[] = { 192, 168 1, 177 };这个是写自己的ip地址么,通过路由器获取到ip信息。byte server[] = { 64, 233, 187, 99 }是谷歌的ip地址?红色部分也不是很懂,希望大家不要喷的太凶
回复

使用道具 举报

发表于 2013-7-5 23:49:02 | 显示全部楼层
byte ip[] = { 192, 168 1, 177 };这个是写自己的ip地址,你可以设置通过自动获取ip信息。byte server[] = { 64, 233, 187, 99 }是要获取信息的服务器的ip地址。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-7-6 12:35:28 | 显示全部楼层
code-AR 发表于 2013-7-5 23:49
byte ip[] = { 192, 168 1, 177 };这个是写自己的ip地址,你可以设置通过自动获取ip信息。byte server[] =  ...

#if ARDUINO > 18
Client client(server, 80);这2局呢,看不大懂,有没有什么比较好的资料看看
回复 支持 反对

使用道具 举报

发表于 2013-8-8 16:24:48 | 显示全部楼层
请问楼主,这是TCP协议的客户端吗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 08:55 , Processed in 0.038801 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表