I am looking for an approach to create a java application for web socket. This application should not use any server's jars.
I say this because I have seen that java client for web sockets are available only for server to server communication. If I need to create it outside the server I have no other go to get those server's jars imported inside.
nv-websocket-client is a new WebSocket client library written in Java. It requires just Java SE 1.5, so it can run even on Android. The size of nv-websocket-client-1.3.jar (released on 2015-05-06) is 62,854 bytes and it does not require any external dependencies. See "WebSocket client library (Java SE 1.5+, Android)" for details.
I'm not sure I understand your question completely but from what I can gather of your question you might want to look into just plain old sockets. It uses a simple tcp protocol to talk between Java applications and is supported natively in Java take a look at this example (http://cs.lmu.edu/~ray/notes/javanetexamples/). Another alternative for server to server communication is to use something like RabbitMQ (http://www.rabbitmq.com/) or Kafka (http://kafka.apache.org/) but those require much more setup and are more complex then sockets.
You are asking for java, however I suggest you cast your net wider and dive into using Node.js (javascript) as your web socket client/server ... nodejs applications run outside the browser and offer super fast asynchronous networking using the V8 c++ javascript engine ... the same engine which lives at the heart of google's chrome browser ... think of it as the JVM for javascript ... you write javascript yet it executes at c++ speeds
To build a socket application you need only a server part where you instantiate a java.net.ServerSocket and a client part where you instantiate a java.net.Socket.
To do that is not necessary any special library.
Those are standard java applications (with a public static void main(String[] args) method) so you don't need a server environment (servlet container or Java EE container).
Related
I have a code running in router that sends UDP packets(using Sendto() function and a string of data) to a particular server whose IP address and port number I will mention in my code.
I want to deploy a server application that could receive a UDP packet and store its information on server or somewhere else not sure right now.
I have decided to use Google app Engine for hosting my server side code which most probably will be having something like recvfrom() function to receive string.
So how and by using what API's can I start developing my server side code.
Google App Engine has a Preview release of a Socket API, but it does not let you create listening sockets. See Limitations and restrictions section at https://developers.google.com/appengine/docs/python/sockets/
You cannot create a listen socket; you can only create outbound sockets.
You can use Google Compute Engine to run any reasonable software on Google's cloud platform, including programs that receive UDP datagrams. You must always pay for Compute Engine instances.
According to the newest edition of App Engine Socket docs for Java, if you're using java 8 runtime you should be able to use java sockets without limitations:
Applications in the Java 8 runtime default to using native Java
sockets with no restrictions: Google recommends that you keep this
default.
That means that it should be possible to use java.net.DatagramSocket or java.nio.channels.DatagramChannel freely to work with UDP.
I am developing system, that consists of client (written in JavaFX) and server. Now I am going to implement server. Users will download clients. Clients will communicate with server (only one server and many clients). Server will communicate with data base and send results. Server will support authentication and different requests (not http of course). Is it a good idea to implement server with Java RMI? If no, could you advice me any good idea about server realisation.
Thanks a lot for future questions!
RMI is bit kind of traditional but still powerful to me ,it has some draw back . But, despite the RMI there is also a chance for you to use java sockets class ? just like a client -server application ...
my question is following up from this question:
Simple Protocol Concept in Java for this setup
The idea is exactly the same i.e client will send request and server respond with some information:
However i want a well known protocol implemtation such that the server/client can be implemented in any programming langguage. So that client Running java can communicate over TCP/IP sockets to remote app written in C e.g.
for this reason, can you recommend any well known opensource implementation?
Just few tips:
Rest interface: http://en.wikipedia.org/wiki/Representational_state_transfer
Corba: http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture
Apache Thrift: http://thrift.apache.org/
Google Protocol Buffers: https://developers.google.com/protocol-buffers/
your own implementation over tcp...
it depend on your architecture and your requirement, you can use TCP protocol directly, Http is another choice, if your server deployed on a http server, i recommend using web service. i hope my answer will give you some ideas.
I'm just starting working with CORBA. Basically, I'm having to implement a Java application that acts as a CORBA client.
At this point, I'm mainly using the Sun JDK (JDK6) tools, including idlj.exe (to compile the IDL that I was given) and orbd.exe (for testing my code), and so far, I've been able to use the idlj and the IDL to create the Java classes, and I also wrote a test server app and test client app that are both now working (I had to write the small server app so that I could test my client app).
As I said above, I'm using orbd.exe as the ORB for my testing.
Initially, I had orbd.exe, my Java server app, and my Java client app, all running on the same machine, and that worked.
I've also tested in a more distributed configuration, where I ran orbd.exe and my Java server app on another machine (testxp), and my Java client app on a separate machine, and that works.
My question is as follows: A lot of the documents, web pages, etc. that I've seen re. CORBA have diagrams showing two ORBs, e.g., a server app and an ORB on one machine, and a client app and another/2nd ORB running on another/2nd machine, with the two ORBs communicating with each other:
client app ==> ORB1 ----> ORB2 ==> server app
whereas, in my testing so far, using orbd.exe as the ORB, I only have been using one ORB.
So, I was wondering how can I configure a test configuration where there are two ORBs as described above?
Can I do that using orbd.exe, or does orbd.exe not work in that type of configuration?
Also, if that can be done using orbd.exe, how do I do that?
Thanks,
Jim
CORBA is an architecture and infrastructure to communicate application in a network. And ORB is the component that serialize (marshal) and deserialize (unmarshal) the calls to IIOP. With CORBA, you can write a code in C# (using IIOP.NET) and communicate with a server in Java.
So, you are right, the communication is made between ORBs.
|client app| <==> ORB1 <--(IIOP)--> ORB2 <==> |server app|
ORBD is an ORB with a Naming Server. It is ideal that you have only one Name Service, you can read about name service here.
Finally, you have many ways to start comunication between ORBs. (a) activate servant in the POA and call method *poa.object_to_string(servant)*, write the string in a file then read it in the client using *poa.string_to_object(fileAsString)*. (b) define server host and port and use corbaloc. (c) subscribe in a name server (best option).
Try to use three process in your test. Name Server, Client, Server.
PS: I like JacORB then JDK Orb
EDIT:
Adding some code to help:
orb = org.omg.CORBA.ORB.init(args, props);
org.omg.CORBA.Object obj = this.orb.resolve_initial_references("RootPOA");
this.rootPOA = POAHelper.narrow(obj);
POAManager manager = this.rootPOA.the_POAManager();
manager.activate();
I have connected to a socks5 server in my java application, and now I want to launch an external application and have all of its connections run through the socks5 server. The external application itself doesn't support socks5.
Any input would be great, scratching my head here..
The 2 trick I know how to do that are to replace the standard runtime library or a similar trick to intercept the OS networking calls or to setup a set of finely tuned firewall rules in the kernel.
Both of these techniques are very OS specific and have no way to da that using java.
Your best bet would be to run an existing socks5 wrapper and let that program start the external application like socksify.
I have had mixed experience with this approach, some applications work, others do not, and never found any logic in it.
YMMV
Another approach is to play a tcpproxy in the Java application (e.g. using the Apache MINA stuff) and have the application connect to your proxy port on localhost. Again this will only work for certain services.
If the external application is written in Java it does support SOCKS. Just run it with -DsocksProxyHost=host and -DsocksProxyPort=port. See [1].
[1]: http://download.oracle.com/javase/6/docs/technotes/guides/net/properties.html "Networking Properties".