Sending data to server via URL without webserver - serial-communication

http://msdn.microsoft.com/en-us/library/fx6588te%28v=vs.110%29.aspx
This example sets up a server that listens to a port and echoes the received data.
I want to be able to pass data to it via URL in a manner such as typing ip:port;data.
Is that thing possible in any way?
I don't want to have any user interface at all. Just type in the address, port and data in the URL and the server receives the data.

Related

Recording websocket messages

I need to extend a HTTP recorder to record websocket traffic. HTTP recorder is in C / unix platform.
I know HTTP traffic will be through port 80 or 443, hence I am able to record it. In HTTP message a new port is communicated, and through that port websocket traffic passes through. Since this port is dynamic, and HTTP messages will be different in different cases I can not parse and get port for websocket.
I think of below logic, not sure if that is going to work. Need your suggestion / pointers in this regard.
Make use of iptables
Forward all the traffic to a different port (where my application is listening) using iptable rules
Then my application should receive the data (hope it is possible)
Then my application should receive the destination information (when data is forwarded from iptables to my application, can I get actual destination ip/port).
Assuming, I get actual ip/port, then from my application, I can send data to actual destination.
I know, its a long way to go, will this approach work.

Http as a source for Nifi - not working as expected

I am trying to send a file through postman with a POST request and that file needs to be saved in the local FS. I tried all the 4 options GetHttp,InvokeHttp,ListenHttp,HandleHttpRequest. Seems like GetHttp,InvokeHttp requires a webservice to be running at the end who is sending the POST request, that would not fit our case use case. I tried using ListenHttp but I am not able to change the default hostname option which it is pointing to localhost. Is there a way to change that?
And I tried using HandleHttpRequest as well, and it seems like the client who is receiving the request should send an acknowledgement to end the connection at the sender side, nifi user guide doesn't provide an example on how to use or configure that. Can someone provide me an example for the use case which I mentioned.
ListenHttp starts an embedded Jetty server and it does not specify a hostname when creating the connector which according to Jetty documentation says that it should be binding to all available network interfaces:
"The network interface this connector binds to as an IP address or a
hostname. If null or 0.0.0.0, then bind to all interfaces."
To use HandleHttpRequest you also need to use HandleHttpResponse... you basically receive a request from a client which turns into a flow file, pass the flow file through whatever processing you want to do, and then send it to HandleHttpResponse to reply back to the client. There is a template here that shows how to use it:
https://cwiki.apache.org/confluence/download/attachments/57904847/Hello_NiFi_Web_Service.xml?version=1&modificationDate=1449369797000&api=v2

Communication between client's webbrowser and server's serial port

I have a server that can communicate (Python) with its serial port. However, I want that anybody accessing this server from a web socket receives a website based on data from the server's serial port. So a (http?) request from the client should cause the server to get data from the serial port (I know how to communicate in python with the serial port) and then respond to the client based on that data.
I have implemented a basicpython socket that can get requests by a server and then get the data from its serial port. But how do I send to the Webbrowser client a response (that must be HTML, right?) based on that data? So hardcoding a whole Webserver would be too much, right? What's the best way to to this in python?

Finding devices in LAN using a server

I am trying to develop a lan chat application. As I looked for the topic, I found that whatsapp, viber etc. use a server which controls all the traffic. The server tells the status of devices and manage all traffic etc. So, what am I trying to know is :
How the server gets the info of devices like, IP address, MAC address etc?
How the data is transferred from one client to server and then server to another client?
Which language should I use server side?
As shown in image, I want to connect two devices, A and B and interchange data between them.
Actually, I'm not sure data always through the server. From what I know, the client logs in at the server the first time it connects only. If client A wants to send a message to client B, it retrieves the IP corresponding to username_B from the server, then exchange of data is done directly between client.
What you should do is to develop a protocol to login at the server and register the client IP, and to retrieve an IP from a username.
For the routers between server and clients, I think it is out the server scope, you just need for NAT.

How to send data to client browsers when a server side change occurs

I have an intranet based CRM application developed in CodeIgniter 2.1 where the application is running on a local Apache server and around 20 clients are accessing it over LAN. This is to be connected to a call center setup where the call center application (running on a separate server) will do a HTTP post with caller's number as well as terminal number of the agent where the call is arriving to a URL of my Codeigniter application. I am using this data to populate a database table of call records.
Now from the terminal number (each terminal has static IP, and a session in Codeigniter is linked to IP as well) I can find out which user (login session) of my application is about to receive the call. I want to find a way out how I can send data from server side (it will be regarding the call like the number who is calling, past call records etc.) to that specific user's browser via AJAX or something similar? The agent's browser needs to display this information sent from server.
Periodic polling from browser by jquery etc. is not possible as the data needs to be updated almost instantaneously and rapid polling up to this extent will lead to high CPU usage at client end as well as extra load on network.
P.S.: I only want to know how to modify the browser data from server end.
In AJAX, asynchronous request/response doesn't involve polling; there's just an open TCP connection and non-blocking I/O. The client makes a request but returns immediately; when the server sends the response, the client is notified. So you can achieve what you want with AJAX's XMLHttpRequest without polling[1]. All you need is a url from which to serve your notifications. You could have one request thread and a general dispatch method, or different urls and different threads for each, depending on how you needed to scale.
[1] Well, to be honest, with very little polling. You'd really need to establish what the session/global timeout was and reissue requests within that time limit.

Resources