Okay, so as the title says, I’m an embedded C/C++ developer.

Right now, I’m working on a project that involves a client/server C application. The server side of the application is running on multiple SoC nodes that are deployed in random locations (they run off a battery and use a cellular modem for communication).

Right now, I would like to poll information about these nodes. So I have a central computer that I call my server, but that is running the client-side application of the project (bear with the nomenclature here). I run my program from the command line with an IP address, and other parameters as an input. It establishes a TCP connection with a node, sends it a request packet, and the node answers with a response packet. I then write this data to a CSV file on the server computer (the one who initiated the request). The socket is closed, and that’s it.

One of the modes it runs in is “live mode”, in which the client instantiates a TCP connection to one of the nodes (running the server portion of the application), and returns data once a second. When data is returned, a CSV file is appended to. Once the program receives an interrupt signal, it gracefully shuts down.

Now I’d like to do a little more. I would like a user to be able to control this application via a web browser.

The hacky solution I came up with is to have a button on a page. When this button is pressed, I do a shell_exec(/srv/bin/myApp_cli <parameters> &). Then through AJAX Javascript, the page starts reading from its output file once a second. It looks at the last line of the CSV file and posts it on the screen. When I want to stop this application, I do shell_exec(killall -2 myApp_cli).

It works, but my god is that a hacky way of doing something that should be easy. These two parts of the larger project: the web portion and the C client server portion; are extremely independent of one another.

My question is.. how can I interface my simple little C program with PHP, or any web language easily (I chose PHP because that’s the only real back-end language I know). What would be the best approach to achieve what I would like to do? Especially in the case in which I run a program indefinitely until I want to send it a signal to stop?

4

The best back end webserver language for an embedded C program is… C!

There are plenty of embedded C webservers that are trivially easy to use, I added civetweb to my service a while ago and it was too easy. Civetweb is a non-GPL fork of Mongoose, but there are others such as NxWeb.

Civetweb has some examples, including ones that include Lua support and websockets if you need push responses to the web browser, all in a handful of lines of code.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật