Native function call from Actionscript3 using sockets - c++

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

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

C++ library for network communication between laptop/device without router

Background
For my project, I'm attempting to control an AUV using an Arduino mega with an ethernet shield that receives instruction from a laptop (running Windows). The server side (laptop) will be written in C++.
Since there'll only be a one to one network using TCP/IP, I am trying to avoid the use of routers in order to simplify the hardware. I found out that you could do a direct connection between two devices (with auto-MDIX).
Therefore...
I have briefly looked into Boost:asio but I think it's probably an overkill (because I won't need to consider multiple clients etc) crossover for what I'm trying to achieve here. Am I right?
Any advice would be appreciated! Thanks.
TL;DR:
Looking for a C++ networking library (that works on Windows) that allows a clean, simple code to do a one-to-one TCP/IP connection.
The simplest way is to set-up your arduino as a web server. See this example sektch for the details.
On your Windows box use a web client library.
This way you can test the arduino even without your client software using your browser.

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.

RDP protocol for c++

Im looking for code that connects to another computer via remote desktop connection and checks if the connection was successful or not.
I packet logged and found out there was a galaxy worth of packets so i was wondering if there was some easy code out there.
There really isn't anything easy about RDP, that protocol stack is huge and builds on the ITU OSI protocols, which includes a fair amount of ASN.1/BER.
Your best bet is the code that's in FreeRDP.
A bit of terminology: you want a "RDP client library for C++".
As others have mentioned, look into the "FreeRDP" and "rdesktop" projects.
With FreeRDP, you're going to get a suite of libraries (each one doing it's thing). With rdesktop, you're going to get a client app (which you have to break the C code out of, and "build" your C++ api around).
If this is a new project, I'd pick FreeRDP over rdesktop, as they have libraries available with your C++ interface already in place.
Do you need to check if an RDP server is present, but not authenticate? In this case all you'd need are the first couple of packets used to negotiate protocol security. You can find the code in FreeRDP in libfreerdp-core/nego.c.
#Blanker1231 : You should have look on rdesktop code , its in c but can be very easily modified to be used in a C++ code , all you have to do is bridge their Struct Stream effectively .
moreover I have worked on a Rdp 7+ implementation ages ago in qt/c++ for a , so recently just for fun of it i used all of my experience and wrote a RDP parser and code generator and open sourced it on https://github.com/shashanksingh/Code-Generator-for-RDP
Right now it dead simple and i am still working on it more intelligent . Word of caution it doesn't generate everything . Examples includes demo.def which on compilation will generate all the class os ms-fscc used in ms-rdp
#Blanker1231 if you ever feel like , just fork the implementation and start pushing stuff in

TCPStream Class for multithreaded TCP server

I'm currently working on transitioning a small console application to a TCP server / client application. The client will connect to the server via any Telnet client, and the server will replicate the standard console interface for each Telnet connection.
I started looking into doing this using the techniques I've learned from Beej's guide to network programming -- accepting the connection and then using fork() to separate it into its own process.
However, I would prefer to maintain my use of streaming IO (the original console application uses cin / cout, using similar functions for the networking logic would make the conversion process much simpler).
I've discovered the TCPStream class, hiding within sockets.h (http://www.gnutelephony.org/doxy/bayonne2/a00215.html)
It appears this class will allow me to use the server with streaming IO. However, I can't find a single example of using this class, nor can I find an explanation as to how to use fork() with it.
Any ideas? Thanks in advance for any help.
I think you are confusing the trees for the forest. One socket class is such a small part of what you need to do overall that it is not worth focusing on that.
If your objective is just to get your project working then just use an existing framework rather than trying to pull individual classes out of a large project. POCO has a TCPServer class that will do 90% of the work for you. QT, ACE and others have similar classes. There is not a huge amount of documentation on POCO but they do cover TCPServer pretty well and you can learn a lot from reading the source code if that is really where your interest lies.