Can a Java web app listen to a tcp port in a local network? - sockets

forgive the triviality of my question. I was asked this question and I wasn't able to find a proper answer so I decided to research this myself and understand. I have spring ,maven etc background. Supposing I deployed my web app on a box 192.168.0.10 in my network, can I listen on the port say 9090 of the 192.168.0.10 and do something with it in my application itself running on tomcat7 on the usual port 8080.
What all this is supposed to do is listen on a port and display a graph on the client side based on the value received.
I was thinking using maven, I will have a jar packaged project handling the networking bit and transfer the control to the web app.Event that it's really blur in my mind.
Can anyone clarify things a little bit for me?
Thanks in advance

Why do you need a different port, effectively your web app is already callable on the port provided by tomcat. You can have various servlets each distinguished by URL, and one can return graphs. There's lots more possibilities, but I don't see any need for another port.

Related

Jupyterhub multiple web applications port problem

at my firm we have a jupyterhub/lab installed and is used by roughly 70-100 people in a secure network that can only be accessed to from work. Recently the idea of hosting web-applications for short time use came up, but we are having port problems. User A is running a web application on port 5000, and User B can’t use the port because it is already in use. Port 5000 is default, it can be changed but this is not the behavior we want. Does anyone know of a way for web-applications to run on the same port in the same environment? Have looked into server-proxy but i do not really understand it. Is the way to achieve this really to be running a vm for each user securing that the port is not in use?
Any help is appreciated

Web sockets and Rest API in same Tomcat based application

I have read up on web sockets providing full duplex connections over TCP which can be used in scenarios where long polling was used to get live updates to client from server. Now I have a Tomcat based application which serves multiple REST based web service response, and I want couple of API's to be implemented using web sockets say to render dashboard with latest data where multiple users are working on them concurrently, is that possible ? My concern here was even if the connection was upgraded to TCP from HTTP wouldn't web socket require a separate port to run than the default Tomcat port 8080. In that case should I house the Web Socket based endpoints separate to the Tomcat based application already running. Please do correct me if any of the above is wrong.
A couple of month ago, I wrote a small Spring Boot webapp with embedded Tomcat that provides both, REST endpoints and websocket support, and both via the same port. So, yes that works... if you wanna sneak a peek: https://github.com/tommybrettschneider/pinterest-boot
Besides that, this post should also clarify things:
Shall I use WebSocket on ports other than 80?

Jboss 5 listen on different ip addresses based on different URL path

We want to harden our Jboss server. We have a web application, and there are two types of resources in this web app
'https://myserver:8443/myapp/local/'
'https://myserver:8443/myapp/intranet/'
We only want the /myapp/local to be able to accessed from localhost 127.0.0.1 and the /myapp/intranet/ can be access from another address from internal network e.g. 192.168.12.12. Is there any way we can configure this? Thanks!
Tony
I found the answer myself. Hope this is helpful for someone who runs into this someday. Here is the solution
https://community.jboss.org/wiki/LimitAccessToCertainClients

Is there a way to make it look like two programs are listening to port 80

I do know that I can't have two programs listening to the same port, but I am wondering if it is possible to fake it somehow, for an example:
My machine has two applications, one listening to port 80 and the other to port 6653.
If I get an incoming connection, let's say mysite.com:80/chat then it would be forwarded internally to the application listening on port 6653 and the data returned from that server would be forwarded back to port 80 somehow.
The reason I want to accomplish this is because there are many firewalls that seem to block connections to ports other than 80.
I have a chat server that I want to run on port 80, perhaps I could get another IP and machine for that, but it feels like too much trouble for a single chat server.
Any helpful feedback would be appreciated. Thanks!
You can probably do this with mod_rewrite if you're running Apache. That link has plenty of examples, including what you want (I think).
EDIT: I see you've updated the tags to say "asp.net". I'm guessing that you're not running Apache, then. I'm sure there is a similar tool for IIS, or you can use a proxy server that does the same thing.
There is a module called URL Rewrite that you can install on Windows Server 2008 (and R2) that is functionally the same as Mod_Rewrite. Download it here: http://www.iis.net/download/URLRewrite

which ASP.NET hosting site allows listening on different ports than 80 and uses .NET 4?

I'm trying to take advantage of HTML 5 web sockets in .NET and the easiest way appears to be something like what this guy does.
I've already tested this myself and it works great, but there are a few problems if I try to deploy this to my hosting site (discountasp.net). Basically, I am not allowed to open up a port on 8080 and listen on it. I then tried to figure out a way to listen on port 80 with IIS as well, but using the HTTPListener, I run into sercurity issues as well. This doesn't seem like it will help since I can't mess with this stuff on the hosting site server either.
So to make my life easier, I think I need to find a hosting site that simply allows me to open up a socket on port 8080 and listen on it. Anyone know of one? Or does anyone know of a workaround (besides sniffing all the traffic on port 80)?