In Qt webassembly documentation there is a mention, than one can use QNetworkAccessManager for HTTP communication with the server that hosts my website. The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
Yes. Your server program runs a QApplication, and the single instance of that class could get that URL.
In other words, you'll document that your C++ program (the executable file obtained by compilation, e.g. with GCC) foo would accept some --server-url argument, and you would start foo --server-url http://example.com/somestrangeurl/
Please notice that WebAssembly is often running inside Web browsers (that is, inside Web or HTTP clients). Most HTTP servers (e.g. lighttpd) are running on Linux OS (and you might use Wt or libonion or some other HTTP server library for them, if you have to code your HTTP server from scratch).
Related
I have two EC2 servers. One runs Windows Server 2012 R2 and the other runs on Amazon's Linux build. The Linux box is used as a web server with PHP doing the scripting. I would like the Linux server to send a string to the Windows server every time a PHP file (acting as a RESTful end-point) is processed.
I've never done anything similar and was wondering where to start. From the research I've done so far, it seems like using Netcat to create a Telnet connection might do the job. If so, what would the boilerplate code look like? Netcat is a pretty old platform and there's not much to be found in terms of examples from a Google search.
I am also open to other solutions that could solve this problem.
The workflow of what I am trying to do looks like:
A user hits PHP file end-point -> PHP or the server it runs on sends a string to the Windows Server -> Windows server receives the string and starts a script
You could think of exposing this as an endpoint on your Windows server using either of:
IIS + PHP
IIS + CGi/Perl
IIS + Asp
or anything else.
Expose a simple page on IIS (Windows web server) and hit that from within your webservice login (Linux server) whenever the Linux server receives a request. The script/page that is exposed by your Windows server could execute the desired script then.
The page/endpoint that is exposed on the Windows server should be protected so that not anyone could execute it (disabling public ips. Restricting only the Linux server Ip in your firewall rules etc.)
Sample
Within your php webservice - $my_var = file_get_contents('http://WinServerPrivateIp/runScript.pl'); // Make it asynchronous if needed
runScript.pl in Windows - Would execute your actual script.
You could look at calling winexe from within PHP. I haven't done it myself but I've read that this should do the trick.
winexe Sourceforge
Some sample code from within PHP here
I hope that this is of some help to you
Regards
Liam
I need to develop a minimalistic webservice.
It should have 2 functions:
senduserdata (a remote app will call "senduserdata" to send info about users, like "ID" and "amount")
sendconfirmation (a remote app will tell "all ok for proccess ID=X, notes are: NOTES)
In past I did a SOAP dll that needs IIS to run, since deployment is crucial in my case and IIS is not always available is it possible to have a standalone exe that exposes the SOAP (or REST) interface?
I succeded in a few minutes using the RemObjects trial and setting SOAP as communication protocol in a server + client project group (note: i need server only).
With a VCL EXE i can deploy much easier (i have lots of customers, and accessing their IIS to install a dll it is sometimes too hard).
Yes, you can use any TCP library for Delphi which includes a HTTP server, for example Internet Direct (Indy). With Indy, you can create a stand-alone application (or better, a windows service) without IIS.
In a RESTful web application, the senduserdata command would be implemented by a URL like
http://example.com/api/users
The clients then use a HTTP PUT or PATCH request to update the users resource.
A senduserdate call for user id 774422 would be written like
LStream := TStringStream.Create('{ "amount":100.50, "currency":"EUR" }');
try
HTTP := TIdHTTP.Create;
try
HTTP.Put('http://example.com/api/users/774422', LStream);
finally
HTTP.Free;
end;
finally
LStream.Free;
end;
In the the Delphi application for server side, a TIdHTTPServer component then listens for HTTP requests for the /rest/users resource and in the OnCommandOther event handler it would extract the request body string, parse it, and apply the changes to the user with the ID given in the resource path (/774422).
i was trying to find some examples that would give me some pointers on how to create an http server within a chrome extension, but haven't had any luck. does anyone know a how to start an NPAPI,NACL http server?
Thanks
Short answer: not possible.
If you want to open a port on a local machine to allow connections, then that is not allowed by the web security model. NaCl runs with the same privileges as JavaScript, no extra holes. However, you may specify extra flags to chrome on start to get more permissions from NaCl, such as open debug port, or get access to raw network sockets.
If you want to 'emulate' an HTTP server to make your extension keep using it regardless of being offline, then it is easier to use the PostMessage API.
Im new in C++.
I need to listen HTTP requests.
Please advice me some good tutorials or examples
Thanks
update:
Platform: Windows
Language: C++
I will explain more clearly what i need
when user clicks row on this page: http://ucp-anticheat.org/monitor.html applications is automatically starts on client machine.
I want to make same thing.
I think on client side is service which listens http requests and if url starts with steam:// service automatically runs application...
Do i need to listen http requests?
What is best solution for my problem?
You can listen to http requests through a web server like mongoose , which can be easily used in C++ http://code.google.com/p/mongoose/ , and here is a good example of using mongoose web server http://code.google.com/p/mongoose/source/browse/examples/hello.c
I m not sure what you mean 'client side', if you are meaning Browser as your client, you can't control nothing outside your browser. If you want to control a machine, you need your client machine to run your exe, that has the code to act based on your server instructions.
You should create a simple server program, create a SOCKET listening on default http, https etc, ports. Usually we do it inside a loop (at each one you make a read).
Now... would be easer if you specified if you are on Unix like OS or Windows, but from now on you can google it. Like sys/socket.h or try "man 7 socket" on almost all linux (at least the ones I know).
If you want to sniff something you can google some specific apps around web.
If i get your question right, you want to be able to launch an application when someone clicks a link with a custom protocol, like steam:// or telnet://. You are looking for an Protocol Handler.
A simple way to register such an application is using the ftype program, as described here.
I am writing an app on Thrift and webservice deployed on Websphere. Thrift client will be calling thrift server which inturn make a webservice call to webservice deployed on websphere.
Where will I host Thrift server implementation since it will be standalone app? Can it be started before/on startup of Websphere app server?
Shall I run Thrift as a standalone and then how will Thrift server get the common VOs being shared between Thrift server (which is client to webservice) and server(webservice hosted on Websphere)?
What should be right approach in this case since Thrift will be opening a socket which is making a websphere call even though both servers are collocated?
Is it safe to use sockets as a medium of rmi/rpc instead of http? What will be security loopholes since port will be opened for communication?
Thanks.
Quick reply will be highly appreciated.
Thrift service might be implemented either as a standalone application or as an webapp running on the same app server. In latter case thrift service doesn't have to serve any http requests, it should just start thrift server on app startup/shutdown. The advantage is that you can utilize all appserver infrastructure: lifecycle, monitoring, JMX, etc.
To share VOs between two JVMs, it's usually enough to make them 'implements Serializable' and add classes to both classpaths. Sharing within single JVM is trivial. So, there should be no problems here.
Yes, socket communication is just fine, even if servers are collocated.
Yes, it is safe enough, if configured properly. Restricting access to corresponding ports with firewall is probably the easiest.