简体   繁体   English

如何使用php级以下的代码进行服务器端编程?

[英]How to use code below php-level for server-side programming?

I have above average html experience, and have also dabbled with a bit of PHP as well. 我有超出平均水平的html经验,并且还涉猎了一些PHP。

I am now getting into Arduino and have connected it to the internet via an Ethernet module. 我现在进入Arduino,并通过以太网模块将其连接到互联网。

The issue is the Arduino doesn't have much memory (30KB !!) so having PHP to handle server-side code is out of the question and multiple pages might also be difficult (maybe not possible even). 问题是Arduino的内存不足(30KB !!),因此用PHP来处理服务器端代码是不可能的,而且多个页面也可能很困难(甚至可能无法实现)。

Obviously this will get into C++ territory which is even further down the rabbit hole, but i would appreciate if anybody could give me some pointers as to which way to dig down instead of having to cover the full basics of C++ (using Arduino has "spoiled" me, i guess). 显然,这将进入C ++领域,甚至进一步深入兔子的洞中,但是如果有人可以给我一些指示,以进行深入研究,而不必涵盖C ++的全部基础知识,我将不胜感激(使用Arduino已经“宠坏了” “我,我猜)。

There are various libraries which help with doing the grunt work as far as coding goes, but i'm having trouble trying to figure out which parts of a library does what, as well as trying to translate between the different methods of each particular library - one certainly needs to know C++ to be able to read the different libraries. 在编码方面,有各种各样的库可以帮助您完成繁重的工作,但是我在尝试弄清楚库的哪些部分在做什么以及尝试在每个特定库的不同方法之间进行转换时遇到了麻烦-人们当然需要知道C ++才能读取不同的库。

One tutorial showed the possibility for a button to be placed on the page like so; 一个教程显示了可以在页面上放置按钮的可能性。

<form METHOD=get action=" (*(baseurl)*) ">
<input type=hidden name=**cmd** value=1>
<input type=submit value="LED Off">
</form>

<form METHOD=get action=" (*(baseurl)*) ">
<input type=hidden name=**cmd** value=2>
<input type=submit value="LED On">
</form>

but the library itself is now defunct, and i can't figure out where the value of ' cmd ' would be used within the newer library that i now use. 但是该库本身现在已失效,并且我不知道在我现在使用的较新库中将在何处使用“ cmd ”的值。

Here is some code remnants that was still on the tutorial page; 这是一些仍在教程页面上的代码残留;

if ((cmd==1)||(cmd==2)){ 
         if (cmd==1)
           {LEDOnOff(0);delay(100);}
           else
           {LEDOnOff(1);delay(100);};
         plen=print_webpage(buf);
    }

es.ES_make_tcp_ack_from_any(buf); // send ack for http get
es.ES_make_tcp_ack_with_data(buf,plen); // send data

In PHP it would be easy to handle it with the GET method, but now i'm baffled how to "catch" that 'cmd' value with just C++. 在PHP中,使用GET方法很容易处理它,但是现在我很困惑如何仅使用C ++来“捕获”该“ cmd”值。

If anyone is aware of the EtherCard library, that's what i'm using - and i could post the relevant .cpp file or functions therein if i knew what sort of keywords i should be looking for. 如果有人知道EtherCard库,那就是我正在使用的-如果我知道我应该寻找什么样的关键字,就可以在其中发布相关的.cpp文件或函数。

Could anybody give hints as to what sort of methods could be employed to make a sparse interactive webpage ? 有人可以暗示可以使用哪种方法制作稀疏的交互式网页吗? There are examples with 'refresh' as well as displaying information about sensors connected to the Arduino - but none that seem to show how a user/client could interact, aside from that old library with the example mentioned above. 有一些带有“刷新”的示例,并且显示有关连接到Arduino的传感器的信息-但是除了上述示例的那个旧库之外,没有一个似乎可以显示用户/客户端如何进行交互。

This question was apparently an 'alias' for "How to write a webserver or do HTTP programming in C++" of which there are many threads on SO with the various suggestions on libraries one can use such as libcurl, netlib and boost-asio. 这个问题显然是“如何使用C ++编写Web服务器或进行HTTP编程”的“别名”,其中有很多关于SO的线程以及关于库的各种建议,例如libcurl,netlib和boost-asio。

The learning experience continues, and this question is now answered as a stepping stone to "where to go next to reply the question". 学习经验仍在继续,现在可以作为“下一步去哪里回答问题”的垫脚石来回答这个问题。

i don't know if we're allowed to cross-link to other questions but here are the links that helped me to get closer to the answer to my question; 我不知道我们是否可以交叉链接到其他问题,但是这些链接可以帮助我更接近问题的答案;

Build a simple HTTP server in C 用C建立一个简单的HTTP服务器

Simple webserver in C++? C ++中的简单Web服务器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM