I'm messing around with a program to track my internet browsing habits and I'm trying to think of the best way to do it. I have some ideas but I'm not sure how feasible they are.
Somehow hook into firefox. I don't think there's an API that I can hook java into firefox with. I heard something about a firefox java rmi add on that I can access from java but I can't find anything. This would restrict me to firefox, which is fine because I only use firefox.
Emulate Windows "netstat" somehow. I don't want to call netstat because that limits me to Windows. This would be a last case scenario
Socket programming. I can set up a ServerSocket to listen on port 80 but not if there is already something using that port, so it doesn't do what I want it to do, listen to what's already going on on port 80.
Use a packet capture library. This seems like overkill.
Any other ideas?
Sure
Check rabbit a java proxy with monitoring,sniffing and filtering capabilities
http://www.khelekore.org/rabbit/
Use a java local proxy to monitor any request from any browser
Related
Is there a way to automatically port forward in java for Socket? Or if you can't do this in java, how else can you do it? Using native functions isn't a problem (I have a feeling that is what I will need), I can add that if it is needed (tho C++ isn't something I really know, I can follow tutorials).
The project I'm working right now has a part in it that has to transfer files but not over localhost, that is why it needs port forwarding.
Yeah you can manually port forward in you router, but that is not something your users should have to do, and most won't even know how to do it.
My specific problem is I have a tomcat comet servlet that my java application connects to. For some reason, I am getting random END events and I cant figure out why. I wonder, as Im trying to weed out whats not wrong, is if windows when connecting to the same ip and port, from within the same jvm, would give two processes the same port? This would make it look like to the server that the connection is coming from the same place? Does it work this way? I open two instances of the application from netbeans, the same JVM, and Im wondering if this can occur?
I wonder, as Im trying to weed out whats not wrong, is if windows when connecting to the same ip and port, from within the same jvm, would give two processes the same port?
No. Windows will always allocate a new local port for outbound connections.
This would make it look like to the server that the connection is coming from the same place? Does it work this way?
No.
I open two instances of the application from netbeans, the same JVM, and Im wondering if this can occur?
No.
The bug referred to in #TapanPandya's answer concerns ServerSockets and explicit bind() invocations. It isn't relevant to outbound connections.
There was a bug in Java 7 some time back which allowed multiple applications to use same port.
JDK-7179799. Also, check similar question Can two applications listen to the same port
I need to test a functionality internal to my company's server whose benefit is evident only when clients run slow (as of latency and packet loss). To that extent, I need to simulate clients on a slow and/or lossy connection (TCP/HTTP). I'm using a Mac, Mountain Lion, and ideally I'd need to run both server and client locally.
One approach I tried to pursue -- unsuccessfully -- was to get hold of some java APIs that allow me to build clients with slow connections. I know JMeter has got something called SlowSockets (or something similar), but I was looking for APIs more focused on slow-performing clients. Any ideas of useful APIs?
Another approach I tried consisted in using a proxy to act as a middleman between client and server. In that case, the proxy should provide functionalities for simulating slow links. I've tried Charles proxy (Mac) and Apache TCPMon, however I seem to miss something when I try to get them at work. With TCPMon, for instance, when I start it in 'Proxy' mode (which is the mode that offers the 'simulate slow link' functionality) I define port for the local proxy, but I can't see how to define the remote host and port. Something similar happens with Charles Proxy; I can set the local port in the Proxy settings, but I can't understand how to define the remote end of the proxy (in fact connections fail saying the remote server is not responding). Anyone having ideas what I'm doing wrong?
One further approach I have tried to pursue is by using lower-level (e.g. OS-based) means; in this case, I tried Apple's Network Link Conditioner. I switched it on and defined my slowness parameters, but when I ping I don't seem to see the expected RTT etc. I've got a feeling NLC has a tight relationship with XCode and iOS testing, anyone capable of putting it at work for testing other (e.g. Java) applications? I've also tried ipfw on Mac, however the manual says ipfw is now deprecated and I don't want to dedicate time to get to know a tool that won't be available soon.
Any idea/help will be highly appreciated.
Thanks in advance.
Is it possible to make my local computer function as a gateway in Java? I need the other local machines to connect directly to my computer to see if they are alive or not.
You could run a Java server program on your desired PC and let it listen on a port. Then you could use other programs (browser, other Java programs etc.) to connect to this port, and send commands to be executed by the Java server program.
If you just want to see if the PC is turned on or not, I'd just use the ping command though. Or see this answer: How to do a true Java ping from Windows?
Surely it's the other way round? Surely you want to connect to the other machines to see if they're alive? In which case see InetAddress.isReachable().
Try this.
Create a Java Server Socket, which keeps listening to the client at some port.
Write a client in Java which connects to the Server, wrap the connection logic in try-catch block....
If your host is alive the try code is executed which contains the code to connect to the
Server, if this connection process fails you will get UnknownHostException, here you can instead type a message that the connection failed.
You could more easily manage and control this by polling for other devices from a central server. If possible, avoid unnecessary client/agent apps that might tax your development and support resources as well as taking up RAM on the client workstations.
There are many monitoring tools that already do what you want. I'd have a look at Nagios, for example.
If you want to develop your own app, do your own quick troubleshooting, or just get a feel for network discovery tools, then take a look at NMAP. You could, for example, search a subnet for anything that responds to TCP:445 and see what Windows machines are alive.
If you do go the Nmap route, please have a look at Nmap4j on Sourceforge. It's a Java wrapper API that simplifies the work needed to integrate Java and Nmap.
Cheers!
Thanks for any answers in advance.
Anyways, I made an android application, (This isn't an android question), and it connects to your computer so you can monitor it. Well I have the server for the computer ready to the client from the phone can access it, it works perfectly. The problem is, You have to port forward, and not everybody knows how to do that. Is there a way so you can programmatically make it so you do not have to port forward?
Thanks again!
You mean you had to set up port forwarding on your router (because you're using a router with your broadband connection)?
No.
You would need to set up a intermediary server on the internet somewhere that both could connect to, then forward the data through that.
You can have both connect to a server of yours. More of a pain than any other method, but guaranteed to work.
I'm not sure about the specifics of the droid, but you may be able to access the droid directly through its IP.
Otherwise you could set up a simple tutorial program, with specific instructions on how to port forward. You could even make a little program to access certain popular vendors port forwarding directly. Maybe just a little thing that asks for a password and connects and does everything automatically. Wouldn't be horribly difficult with some vendors.