HTTP 与 TCP/IP,将数据发送到 Web 服务器 [英] HTTP vs TCP/IP, send data to a web server

查看:36
本文介绍了HTTP 与 TCP/IP,将数据发送到 Web 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在做一个需要使用 Arduino Nano 的项目(http://arduino.cc/en/Main/arduinoBoardNano) 将数据从温度传感器发送到网络服务器.

I'm currently working on a project where I need to use an Arduino Nano (http://arduino.cc/en/Main/arduinoBoardNano) to send data from a temperature sensor to a web server.

起初我认为这很容易,因为有很多很棒的库可以帮助处理 POST/GET 等.但是,我的教授刚刚告诉我,我需要使用 TCP/IP 将数据发送到服务器,据我了解,POST 和 GET 是 HTTP 方法.

At first I thought it would be easy, since there are so many great libraries out there to help with POST/GET etc. However, my professor just told me that I need to send data to the server using TCP/IP, and as I understand it POST and GET are HTTP methods.

有人可以向我解释 HTTP 和 TCP/IP 之间的区别吗?特别是因为它涉及将数据发送到 Web 服务器.我正在寻找一个不太技术性的答案(我对这一切都很陌生).

Could someone explain to me the difference between HTTP and TCP/IP? Specifically as it relates to sending data to a web server. I'm looking for an answer that isn't too technical (I'm pretty new to all of this).

最后,如果有人有让 Arduino 执行我上面描述的操作的经验,我将非常感谢您的指点.

Finally, if there is anyone out there with experience making an Arduino do what I've described above, I would really appreciate some pointers.

谢谢!

推荐答案

HTTP 是一种主要用于浏览 Internet(IE、Firefox 等)的协议.它建立在 TCP 之上,它提供了两台计算机之间的可靠链接(如果数据包丢失 - 它会被重新传输).TCP 本身建立在 IP 之上,IP 提供统一寻址以在计算机之间进行通信.TCP/IP 是 Internet 和 99% 其他网络的基础.

HTTP is a protocol used mostly for browsing the internet (IE, Firefox, etc). It rides on top of TCP which provides a reliable link between two computers (if packet get lost - it is re-transmitted). TCP itself rides on top of IP, which provides unified addressing to communicate between computers. TCP/IP is a basis for internet and 99% of other networks.

基本上这意味着,如果您正在使用 HTTP 进行通信,那么您正在使用底层的 TCP/IP 进行通信(但我确信这不是您教授的意思).

Basically it means if you are communicating HTTP, you are doing it with TCP/IP underneath (but I am sure this is not what your professor meant).

Arduino Nano 并不支持所有这些,因此您需要介于两者之间的东西,它将 Nano 信号转换为 TCP/HTTP 通信.

Arduino Nano is not supporting all of those, so you need something in between, which will translate Nano signaling to TCP/HTTP communication.

您的一些选择是:

  1. 通过串行与 Nano 通信并使 PC 将您的串行协议转换为 HTTP/TCP.
  2. 将 Nano 与其他一些支持以太网/Wifi 扩展板扩展 (Uno/Mega) 的 Arduino 板切换,或者选择一个单独包含以太网的定制板.
  3. 使用另一个带有以太网屏蔽的 Arduino(Uno/Mega)作为附加板,通过串行或在 RF 模块的帮助下与 Nano 进行通信(我过去亲自实施了此选项).
  4. 另一个不同寻常的选择是使用音频线将 Nano 连接到您的 Android 智能手机并使用软调制解调器库.(https://code.google.com/p/arms22/issues/detail?id=2),其中包含针对 Android 的实现并为 Android 编写应用程序
  1. Communicating with Nano over Serial and making PC translate your Serial protocol to HTTP/TCP.
  2. Switch Nano with some other Arduino board which supports Ethernet/Wifi shield extension (Uno/Mega), or choosing a custom board which contains Ethernet by itself.
  3. Using another Arduino (Uno/Mega) with Ethernet shield as an additional board which communicates with Nano over Serial or with the help of RF modules (I personally implemented this option in past).
  4. Another unusual option is to attach Nano to your Android smartphone using Audio cable and to use soft-modem library. (https://code.google.com/p/arms22/issues/detail?id=2), which contains implementation for Android and write an application for Android

您提到的Web服务器仅根据定义支持HTTP,因此如果您想通过TCP进行通信,则需要使用一些TCP服务器.

Web server you mentioned supports HTTP only by definition, so if you want to communicate over TCP, you will need to use some TCP server.

提供用于可视化传感器数据的图表的现有网络服务之一是 https://xively.com/,它的 API 基于 REST,它运行在 HTTP 之上.但它不是唯一的.

One of the existing web services to provide graphs for visualizing Sensor data is https://xively.com/, its API is based on REST which rides on top of HTTP. But it is not the only one.

这篇关于HTTP 与 TCP/IP,将数据发送到 Web 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆