I'm developing a MVC C# applications, and i need to send raw commands to the serial port, and i want to know what is the best way to do this, is there a way to do this with c#(i guess not because this code is running on server side, and the hardware is in the client side)? Or i need a Java Applet?
I've been checking this but it is for printing, would it work?
(i haven't tested it because the terminal that i want to send the commands is being delivered)
I assume you're using an ASP.NET MVC web application and now want to access the client's (browser machine) serial port. This isn't possible with ASP.NET MVC without additional client software like a signed Java Applet or other software installed on the client machine (like a service, browser plugin or background application.)
This thread may be of use:
How to read from Serial port in a webpage
Related
i am developing an android application in which the server side execution is done using a simple java udp program.i want to know how i can host this application because i need a static ip server to run the java program.can i run my java program in a server.is it possible if yes how?
You'll have to write a listener in some language (PHP, Java, Etc.). As for a static ip address, you can also look at a dynamic ip redirection service like no-ip;
http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html
You can use a personal machine thats always online, or you can try to use a shared hosting plan that allows you to have a listening port open. A web service will likely be easier to work with than having some custom UDP/TCP connection.
Well, I've been playing around with php for the last week or so, and I am wondering how I would use it to get data from a Java application. i.e: the php script sends a request to the server and asks for a response. In my particular case I want to do just that: I would like to have a java application waiting, and the php would "ask a question" to detemine if it is on or off (the server would not respond if it is off, and would if it is on - type of thing).
My question is: How do I communicate with a php script through java. How do I make requests to an application through php?
Any ideas?
If your PC is the server, then you can write a Java based server that listens to a socket -> then do something in java program when communication is received. Here's a simple example.
For real life implementation though, I'd suggest you use the PHP/Java Bridge instead. It's much faster and optimized for this sort of operations.
PHP has the ability to make web calls, open and communicate through sockets, SOAP, RPC, etc. It all depends on how your Java program would be listening.
Additionally, PHP can be written as a socket server, so your Java program could talk to it via web calls, socket or any other sort of server technology you choose.
OK, I'm new to server-client applications, and i need some basic information, so forgive me if my question is not clear...
I want to make a chat application that would function like this:
Client A sends information to server, server sends the same information to client B, and vice versa... Think of it as of a simple chat program.
All communication is done through sockets, so i would have a server socket application, and a client socket application... I want my client application to be on my PCs and server application to be on a remote server ( it would be hosted on some free hosting websites).
My question is how do I start that server application on that remote server?
Thanks in advance!
If you are just trying to make a chat client, I don't think you would need an intermediate server. Just connect two machines using server and client sockets
SERVER:
ServerSocketChannel serverSocket;
serverSocket = ServerSocketChannel.open();
serverSocket.socket().bind()
serverSocket.socket().accept()
CLIENT:
SocketChannel clientSocket = SocketChannel.open();
clientSocket.connect();
Of course you would have to use the bind and connect functions properly. Read up on their API's
The remote server can be started manually. (If you do not have access to remote server or if you are hosting your server on some third party infrastructure, then they might have a way to do it.)
To be able to start it remotely via some program, you again need a server on the remote machine that listens to this kind of requests.
Usually, you want an application that is running all the time at your hosting provider (like a web server or perhaps inetd) to start (or embed) your application. The details will be determined by what your hosting provider provides.
If you're using plain sockets, you should look for some remote server with SSH login. You're able to start your application on the shell then, sth like:
java -jar yourapp.jar
Free hosting websites are rather targeting customers that want to host their website. In my opinion that is not the best choice for hosting a socket application.
For developing purposes, I'd stick with the local machine for the beginning. Running/testing server/client connections on the same machine is much easier as you don't have to work on two different machines, copy code, etc.
This tutorial is relatively short, but fully covers basics of Java networking. And it is right about simple chat.
We need to develop centralized device management based on java. So Could you tell me how to write servlet to read serial port from client with usb token?
Not easily. In order to access resources on the client outside of the protected "sandbox" in the browser you will have to do it using a signed applet that communicates with the serial port and then back to the server (through some servlet interface like a web-service, for instance)
Alternatively, you can write a "real" client application that you would have to distribute and run on the client machine. This application would, in turn, communicate with the serial port and with the server through some communication method. This could also be a servlet-based communication like a web-service.
Point is, this has very little to do with servlets as a servlet executes on the server and has nothing to do with the client.
I have a multiplayer game server application written in Java which connects to player clients when they join the multiplayer game via a socket. The server application (a JAR running in the JVM) is listening to a port (e.g. 9999) for incoming connections from clients.
I want to add a website to minitor the entire project which contains information taken from the running game server(s). One way would be to open a socket from the site (a PHP socket for example) to the gameserver (Java) and implement a custom protocol for taking data from the server. But that method is time consuming as I need to add support for each type of datum I want to pass to the monitoring website.
I was thinking if there is a way to write the site in Java and simply communicate with my gameserver via a direct link. RMI would be a solution I assume since both my JAR and my WAR can communicate through it, but isn't there some better way to build both the web application and the gameserver application inside the same JAR file? So that when my gameserver runs, the web application runs too?
this looks to me as the fastest way to have an admin console. Just transform your server into a war application which contains both your game server with an open socket for clients and your administration pages. To start your server simply drop it into a tomcat.
A cleaner approach which does not require some self-created protocol would be to have your server use mbeans for all key objects which you would like to admin. But this needs some coding.
Cheers, Sven
You should have an embedded web server in your game server. Try Jetty (http://jetty.codehaus.org/jetty/). It's quite easy to embed in any java application.