Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have never done any web development stuff i only did a simple 6 hour course on udemy for node.js but i have a decent understanding of c++ so that's not a problem at all. but the actual problem is how would i send for example some long characters like "98AD7NB4B" something like that to my node.js server? all what i know about that is that i need to send it as application/json but i really didn't see any example on how to send and receive data from my c++ app to node.js server. any help is much appreciated.

What I have tried:

i did not try anything sense i really don't know how to do it actually.
Posted
Updated 1-Aug-19 14:01pm

1 solution

Quote:
how to send and receive data from my c++ app to node.js server.
If the Node.js process and C++ program are on the same machine, then perhaps an IPC might help you. What you can do is you can use the local sockets and make Node.js listen on a socket—UNIX Sockets for instance.

Can node.js listen on UNIX socket? - Stack Overflow[^]

What can be even better approach for this—and possible in case your processes are not on the same machines, such as client-server model—then you can utilize the networking APIs of C++, and send the request to Node.js process. Check out this article to learn a bit more on this topic, Socket Programming in C++ using boost.asio: TCP Server and Client[^]. Last but not least,
Quote:
i need to send it as application/json
This requires that you understand that JSON document itself is of a specific format, you cannot just make a string and assume it to be a JSON document.

Check out what a JSON document is, JSON[^]. But, one thing is for certain, a JSON document is still a string. So in C++ program you only need to POST a string and on Node.js you can capture that from the request body.
 
Share this answer
 
Comments
Member 14130865 2-Aug-19 9:03am    
@Afzaal Ahmad Zeeshan thank you for this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900