Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I want to develop a program, not language specific, that can redirect ANY connection to another one, like a proxy server, but for all connections. The language doesn't really matter, but is there a way to do this without modifying raw windows apis and such? I'm going to attempt this in java, but I can import C and C++ code with JNI. Also, what about mac/linux?
You should certainly consider/evaluate using TCP/UDP splice. It is a well-known mechanism for building proxies and is fairly efficient in terms of copying data form one connection to another.
URL: http://linux.die.net/man/2/splice
Java is the wrong language to attempt to do this in. Even if it is possible (e.g. on Windows), the real work would need to be done either using external utilities, or using native library calls.
Attempting to do this for multiple operating systems makes this even harder. The implementation mechanisms are bound to be different.
I don't know how you would do this in Windows, but on a modern Linux system you might do this using "iptables" to enable and configure the network packet processing in the OS kernel. This requires root privilege, a good understanding of the way that network protocols, and care ... since it is easy to "brick" your networking to the degree that you need console-level access to recover.
(And if you are using OS-level virtualization, it can get particularly complicated ...)
FWIW - It is possible to install and use a port of "iptables" on Mac OS/X ... thought it is apparently not supported by Apple.
On the other hand, if you are simply trying to have a Java application direct all of its own outgoing network connections via some kind of proxy, then you should be able to do this by configuring a custom SocketFactory implementation.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
How to run node.js, Java and PHP application on same server and same port, I was trying to run but unable to run.
You need some kind of HTTP proxy layer in front of all this, typically Apache httpd or NGinx. From there you can configure different paths to go to different applications if necessary.
The configuration directives vary considerably depending on the solution you're using, but you can have / go through to PHP and /node go through to Node, while /java goes somewhere else entirely. Just make sure your sub-components are using non-conflicting paths so they can all play nicely together or you'll have to do a lot of ugly URL rewriting.
You could use the varnish cache as a load director and set up different back-ends for each of those servers. Then you could parse the incoming urls to redirect to the appropriate application server. You can absolutely run all of those app servers on the same machine, with varnish listening on one port, and all the other services listening on other ports. It would be easy to firewall those services from external access as well.
Running each service on different machines is also entirely possible and easy. We've used this solution numerous times in different environments because Varnish is extremely light-weight, reliable, and does not have the overhead of a web server such as Apache or nginx which, while good options, can be overkill.
You also get the added benefit of the robust caching it provides. Bonus!
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have a Windows service written by another developer who no longer works with me. It was written in C# with .NET 4.5 requirements. Our solution is making the move to Linux and the daemon naturally needs to be converted.
My dilemma is what to rewrite it in? C++ or Java? The daemon is not complicated. It's simply a controller for our other applications to ensure if they crash or are killed they are restarted. Aside from that it performs health checks through a named pipe and is controlled via a password protected web socket via a separate management Tomcat web interface and writes all of it to logs.
Please put aside any suggestions of "write in what you're most comfortable with" I have a fair amount of experience and knowledge in both languages, and I'll learn whatever else I need to as I go. My concern is the feasibility and effort to accomplish everything I need. I don't have any particular time constraints, but if one language is a fraction of the time of the other then maybe that's a better solution.
Writing it in Java looks like the easiest solution currently, but writing it in C++ has the advantage of being native no-frills code. However, I haven't ever written any web interface or socket code in C++ before, so I do not know the effort involved with that.
To break down my requirements:
Linux
Web interface for control
Named pipe for communicating with client applications
Existing code needs to be heavily refactored
Is C++ or Java more appropriate?
Edit: added more info
Edit2: I guess I should have mentioned that the code needs to be heavily refactored anyways. It was originally written in such a way that renders it difficult to make changes and additions. So rewriting is a cleaner solution at this point. As I mentioned, it's not a large program. Just a controller service.
Porting the solution to .Net Core may the way to go. It will run on Linux (and Mac for all intents and purposes...) and most of your codebase may need minimal refactoring. The only concern is if .Net Core currently has the features you would need supported in the app. And, .Net Core is still in preview.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
In recent discussions on stackoverflow I have discovered that many/most web hosts dont allow java servers to be uploaded as they open ports and create a vulnerability in their system. Without paying extra for a java web host, how is possible to by pass this issue? Can php be used to somehow wrap the java programmed socket, or even write the socket itself in php? This is one method I have heard, but surely the host would look at this no differently than a java written socket- a security threat?
Whilst i'm on topic, how is it that paying more for a java webhost all of a sudden makes their system less vulnerable? Is this just a con to extort a little more by allowing ports to be open if your willing to pay for it, or is their something that i'm misunderstanding?
Thanks
Host it using a dedicated or VPS(virtual private server) below are 2 of my personal cloud/vps providers that i use. You can look around for more but yeah shared hosting in my opinion is for entry thing or when you don't want to have to worry about the underlying platform. If you have a understanding of linux and managing your own servers then i would go for vps all the way.
http://aws.amazon.com/ and https://www.digitalocean.com/
With regards to the PHP part of the question as I stated in my comment if you have ssh access you can run your PHP script php myscript.php though i am not to sure how you would wrap your java service.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I seem to be confused on a few levels of understanding Java, here is what I am curious about:
Is Java a client-side and server-side language?
Is it more a client-side or server-side, if both are applicable?
I don't know if this is the correct way to put this, if it isn't, please kindly me inform me of where this question would do better.
Thank you so much!
Is Java a client-side and server-side language?
It is a language. It is not specifically client side or server side and it can be used in Blu-ray players and many other devices where there is no client or server.
Is it more a client-side or server-side, if both are applicable?
It is use more widely on the server side.
Why does it perform so poorly either way?
It doesn't perform so poorly. It is less popular on the client as it can require a large download and has suffered some security concerns lately. It also doesn't run on every device whereas Javascript is more widely supported.
JavaScript is a client-side language.
Not true, Javascript can be used in Java and is used on the server side stand alone. see Node.js
Java can be used as either. You can write thick client applications, server applications (web or other), or applets that get embedded in browsers, webstart which is initialized via a browser but launches more like a client-side java application.
Java in the browser is generally a bad idea, there have been many security issues, and, imo (and this is very subjective) it sucks for ui (not the code, but the user experience).
Java has huge market share for server side business applications (web or otherwise) especially in the enterprise space.
Java doesn't perform poorly at all. It often performs on par with compiled code (such as C++). The only challenge with Java is that because it is cross-plaform it will sometimes be challenging to work with platform specific things (e.g. directx).
There is a big difference between Java and Javascript.
You might want to look up both.
Javascript is mostly used as client-side language, and Java is most used for applications and or websites.
It's unclear what you mean with poorly performance, you might want to update your question for that part.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is not about restricting opening multiple instances. I wrote a little app that creates reports and send scheduled emails. This app is on a common drive folder that everybody in our company has access to.
I want to set it up the way so that it would really execute only from my computer (like a server). However, all other people could open it and see all the processes that are going on at the instance that is open on my computer and could also make modifications etc
How can I do it?
A single copy of an app running on a server and handling requests from multiple locations... that's called "client-server" and you have essentially two choices:
A modern HTML-based web application (aka "thin client", but the "thin" part is debatable nowadays). The user interface is implemented in HTML/Javascript/CSS, runs on the client's browser, and interacts with a web server over the network (HTTP or AJAX or both) to execute the application logic. The main advantage of this is that the client needs only a modern web browser and can be run on any platform that supports the browser (Windows, Linux, iOS, MacOS, etc)
A "fat client" application. You write the user interface using Java/Swing/AWT/GWT/etc, and a server component also using Java. They communicate over the network using whatever you want to layer on top of TCP/IP. This can also run on many clients but they must have Java installed, so iOS is probably out. And clients may need to install Java, and some users may not want to. I.e. some clients might encounter a barrier to running your app.
A detailed explanation of how to write client-server apps is far beyond the scope of SO. You'll need to do a lot of reading and studying.