HttpListener class in c++? - c++

I have found in this link how can we open a port to communicate with it with few tests (sensing messages) and seeing if it received well those ones sent.
http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
I would like to open an URL
http://localhost:8080 (a port)
to test.
But it seems that it's only working on C#.
Do you have any idea if it's working on C++?

For a portable library, you could use cpp-netlib.

The link that you mentioned is for .NET Framework. Then you can use only with C# (or Dot Net languages)
You have this option for Microsoft projects:
https://github.com/Microsoft/cpprestsdk
Reference: https://blogs.msdn.microsoft.com/christophep/2017/07/01/write-your-own-rest-web-server-using-c-using-cpp-rest-sdk-casablanca/

Related

signal/Textsecure bindings for c/c++?

I am trying to create a signal/textsecure client using qt and C++, however i cant seem to fibd any C++ bindings for it.
the only bindings i can find are for Go (https://github.com/nanu-c/textsecure/)
is there any way to connect C++ with signal?
edit:
i wanted to clarify some things:
-im talking about the messaging app called Signal (https://signal.org)
-i am trying to write an app for ubuntu touch and am developing on manjaro linux.
On Linux or Unix, you probably want to communicate with other remote applications using some communication protocol, such as HTTP or HTTPS or SOAP or JSONRPC or ONCRPC. Of course read about socket(7) and before that Advanced Linux Programming then about syscalls(2). Consider reading a textbook on Operating Systems
Be sure to study the source code related to Signal. Read their technical documentation.
You surely need to understand the details. So take a few days or weeks to read more about them.
If you want to use some web service, you need to read and understand its documentation and when and how you are allowed to use it. There could be legal or financial issues.
Then you might use HTTP related libraries (e.g. Wt or libonion server side, and libcurl or curlpp client side).
See also in April 2020 the ongoing HelpCovid free software project (for Linux), at least for inspiration. We are coding it in C++.
after a little more digging i found that textsecure bindings are now renamed to libsignal.
after finding that out i found a lib for c/c++
https://github.com/signalapp/libsignal-protocol-c

SciDB C++ (Windows) Connection using Protocol Buffers

I am trying to connect my scidb server directly via sockets using C++ under windows environment (Winsock2).
I could only find a python example below for the above purpose which seems quite outdated.
https://github.com/artyom-smirnov/scidb4py
The .proto file shipped with the SciDB 14.12 and the one used in the python example are very much different so the example does not work with the SciDB 14.12.
If someone could help me with preferably a C++ (Windows/Linux) working example or update the existing python example.
Atleast if someone could guide me to the documentation part which explains how to use the message format outlined in the .proto file and what to expect in return.
Thanks.
I believe what you may be looking for is https://github.com/Paradigm4/shim.
It is a HTTP API for SciDB. All you have to do is to install this together with your SciDB. You would then use directly your Winsock (or a HTTP protocol library) directly in C/C++, connecting to the SHIM instance.

Want to use native C libraries in a web application, what are my options?

I have many legacy C libraries used for numerical analysis and scientific computing (e.g. simulation) that I want to use in a web application I am building (so far I have only been using Javascript to make a user interface). What options do I have in doing this on the client side and/or the server side? I heard about using native client with chrome, but I dislike that the client has to turn on the native client flag to do this.
On Server Side:
To begin with CGI (Common Gateway Interface) is the most basic method to be able to use native C libraries in a web application - wherein you delegate an executable (say written in C) to generate the sever side web content.
But CGI is very primitive and inefficient. Each command can result in creation of a new Process on the server. Thus here are other viable alternates:
Apache Modules let you run third party software within the web server itself.
FastCGI - Single Process handles more than one user request.
SCGI - Simple CGI
Refer: http://en.wikipedia.org/wiki/Common_Gateway_Interface#Alternatives
On Client Side:
Good News & Bad News:
You can use PNaCl (Portable Native Client) in chrome. It will be turned on by default.
BUT the first public release is expected in late 2013.Look for PNaCl
You can't do much on the client side - there's no way you can expect the client to have these libraries, and no safe way to download and run them.
The simplest way is to write your server side any way you want, and access them through a web interface. Many languages customarily used for server side scripting can access native C libraries, or you can even write ordinary C applications and run them as scripting agents.
In the "really exotic" category, it is possible to run what starts as C code in the client
if you embed it in a sufficiently protected environment. For example, see the description
of how sqlite (a C database application) was made into a 100% pure java application by
embedding a mips simulator written in java.
http://blog.benad.me/2008/1/22/nestedvm-compile-almost-anything-to-java.html
Looked at Wt yet? Its pretty neat.
Also you have options to code in cgi(ugly).
Although not C, its written in C++. If you can ignore that part: Wt at your service
For doing it client-side, you can use Emscripten. However, this will most probably require some refactoring of your existing code to fit JavaScript's asynchronous main loop requirement.
Note that Emscripten isn't a proof of concept or something like that. It is very powerful and already used to port complex code to the web. You can take a look at the demos (listed in the above URL) to see what can be done with it.
It sounds like you're best off to represent your legacy C library methods as a kind of (WEB) service at the server side. A raw CGI application seems to be a pretty low level point for this approach, but is generally right.
There are C/C++ frameworks available to create webservice servers, and client side libraries that support webservice access and data representation. For the server side you could use gSoap for example.
Another possibility would be to use the webserver of your choice to transmit ordinary files and use a custom webserver (which wouldn't need to support the full HTTP spec) wired up to your C code to communicate with client-side Javascript.
Two minimal webservers you could use as base are libuv-webserver and nweb.

Native function call from Actionscript3 using sockets

Is it possible to remotely call c++ native functions from actionscript3 flex 4 application? Can some suggest any sample code? I'm fine with writing a Adobe AIR app. I found a blog giving some ideas, but there was no code
You can use the Socket class to set up a TCP connection to a server that happens to be a compiled C++ executable, and could even be running on the same machine (localhost), that is a very typical use of the Socket class.
But the way your question is worded, it sounds like you want your swf to make function calls to a C++ compiled DLL or similar, which is not possible. Macromedia's Director product allowed this sort of thing with its wonderful Xtras native plug-in architecture (COM based), but the Flash Player has no equivalent**.
**EDIT: Turns out there is some equivalent functionality available for the AIR 2 runtime environment. I'm adding this for the sake of completeness, even though you did not specify that your app is an AIR app.
Check out this Adobe post: http://blogs.adobe.com/cantrell/archives/2010/03/extending_air_applications_with_plugins.html
and this:
http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html
also this example:
http://www.adobe.com/devnet/air/flex/articles/air_screenrecording.html
Have a look at Alchemy : http://labs.adobe.com/technologies/alchemy/
You can connect to a TCP server in Flash with the Socket class.
The security requirements for serving policy files can be a bear if you're working in Flash Player rather than AIR.
These examples may help, though I can't guarantee they're up to date for security requirements:
Adobe example: socket policy server
Adobe example: Telnet client

Simple C++ Instant messenger

I want to make a very simple c++ instant messenger for lan networks and internet (direct IP connect). I know little about sockets. I searched the internet, but nothing really helped. I would someone to suggest a howto/tutorial/guide. I just want to send and receive messages (in a console window, I'll create the gui later). I want it to be for both Linux and Windows. Thanks in advance!
Checkout Boost.Asio. It's portable, and it's also got an example that implements a simple chat.
check out Boost.ASIO
There's some source code here for a C/S chat application that you could probably use to get started.
Mas.
Example Code
Use boost, cross platform, under the link, straight forward example for client-server chat.