On a computer I want to run a web-based application which is served by a server and this application have to access an RFID reader.
I have set this computer to connect to the server via wireless LAN and connect to the RFID reader via an Ethernet cable (tried both straight through and crossover cable). The reader cannot connect to the server directly because of the mobility needed.
Setting up the connection appear in the image below. The server assigned IP address for the computer using DHCP. Connection between the computer and the reader have set by static.
Clearly, the computer can access both the server and the reader but 开发者_如何学运维the server cannot access the reader as I needed.
EDIT:
The application is developed using Python with Django framework. To connect to the reader I just simply used socket
.
import socket
HOST = '192.168.1.21'
PORT = 50007
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soc.settimeout(2)
soc.connect((HOST, PORT))
I would implement a java-applet and upload it on the server. When user opens a page from this server, java applet loads and starts working. Applet is running on the user's computer context and can access RFID reader, and pass this information to the server.
If accessing RFID-reader requires to involve dll-libraries or any native OS modules, then this applet has to be signed. Use keytool and jarsigner tools from Java SDK to sign the applet before uploading it to the server.
Here you can find information on java networking.
And here you can find information on java applet technology
it depends on several things like "is this just a one-time thing/one reader + one computer" ? OR is it some application that you plan to rollout etc.
the "clean solution" would be as @Rafael pointed out to use some client-side code either a Java applet, an ActiveX or a Flash-based one... any of these are not easy to get right and are security sensitive and need special attention...
IF you have a "one-time scenario" which is allowed to be messy (NOT for deployment/rollout etc.!) then you could do any of the following:
change the network configuration and create routes to make the computer the "middle-man" for the RFID scanner
install some tunnel (ssh-tunnel) on the computer which allows the server to communicate with the scanner via the computer
use some HTML5 websocket (browser/version-dependent, see http://dev.w3.org/html5/websockets/) approach in your web application and try to read the data from the scanner this way and forward it to the server
精彩评论