I have two devices that connect to each other with bluetooth.
Now I have made a socket connection between the two and I want to send a file/upload to the ip address but not to the device.
Not just a file but an Index.html file, so you can actually view the file from your desktop's browser.
In a source, i saw that this is possible on the WiFi IP adress with the port. But I can't find how they exactly do it.
So if you go to e.g. http://192.168.1.xxx:10130 in your browser you could actually see the index.html file as a normal webpage. Is this possible, and how would you achieve this, toghether with sending images.
This is something I really need.
Related
I have seen in many apps that when VPN is connected you can get inside the app and if you are not connected you can't get in.
How can I do this with Java programming?
Write your program like it would access any other local network resource. Once the user connects to the VPN, the network resource will become available and is handled further down the stack. No need to account for a VPN programmatically in your application.
I'm making a project in java using Sockets that consist in connect a DNS server having a url and receive the IP, but that IP will be from a host where the picture is hosted in internet (doesn't matter what picture) and the last step is to get that image and save it in a text file, in binary. The thing here is that I need to show the PDU that I send to the DNS server and the answer. Also need the PDU from the others HTTP querys to download the picture.
I'm quite confused, I have never use Sockets before, if anyone can show me how to do or give me where find information about I'll be very thankful. Thanks.
I have been trying to write an app that generates a personal WiFi hotspot from an android device, that funnels webpage and file download requests through the host's mobile data connection. I have managed to request and download the files, but they are being stored under the phone, on the sdcard\toSendOverWifi\ folder I created.
Quick list of activities done:
Recieving device sends webpage/file HTML address request to host
Host downloads file over 3g/4g/LTE data connection
Host saves file(s) to sdcard\toSendOverWifi\
(not done) host sends file out to recieving device (only connection)
Ihave not found a class and/or method to send the downloaded files over WiFi to other devices.
What class/method do I need to accomplish this? And is it compatible with non-rooted devices?
You need to use TCP/IP sockets as usual.
My goal is to send data from a PC to a Viewing Station (running Linux, on the same network) so that the user at the Viewing Station (VS) can view a graph of the data. I am not allowed to install any applications on the Viewing Station but it does have a browser (something like Firefox or Chrome).
The only way I could think of doing this is to create a java applet which is opened in the browser (on the viewing station), which reads data from the IP address/ port on the viewing station.
Is this possible? How can I go about doing this? Thanks
edit: I cannot send the data to be graphed, outside of the local network. The data is sent from the PC to a local IP address where the viewing station is located.
Scenario:
PC starts sending data to be graphed, to a fixed IP address (where the viewing station is located).
User opens up a browser in the viewing station and opens something that shows the graph. The graph should contain the data received from a predefined port/IP address.
New values are added every 240ms.
edit2: We have shelved this feature for now so I am unable to try any of the mentioned solutions. Thanks for the input though
If a server-side solution is not practical, I'd look to implement simple graphs using JS and the HTML 5 canvas. For more complex graphs, find a JS API.
If a server-side solution is practical, use JFreeChart (or JCharts etc.) to produce an image on the server-side, then provide that image to the client.
Although browsers may be installed on the client, it does not necessarily mean that Java is installed & enabled in those browsers.
Use JCharts. It allows you to make graphs and charts and display them via servlet, applet, or standalone UI. Code it up into some servlets on your server side and then you can view them on the client browsers.
The main problem with your plan is that you cannot 'push' data to your viewer unless there is a service there to accept it. If you cannot install such a service, your options are limited.
1: Map a network drive. The 'producer' dumps the data here, and the 'viewer' can read it. It is unlikely given your restrictions that you will be allowed to do this.
2: Use any of the graph libraries suggested by others and configure your webserver to restrict access to a whitelist of hosts. Your 'producer' runs a webserver which will only serve pages to a specific IP or subnet, your 'consumer' connects to said webserver. See here or here for setting up a webserver which only allows access from a specific IP.
I am using rxtx api to read data from a GPS device over a com port. Right now I'm finding the correct com port by reading a config file and looking for the port listed. The problem that I'm having is that if the device is unplugged the com port could change then the user has to know to change the config file. I wrote an app similar to this in c# and was able to list the windows device name instead of the com port and I cycled through the com ports until the device name matched the name in the config file. Using that method nothing in the config file has to change even if the com port being used changes. Is there a way to do that with the rxtx api?
Thanks in advance!
If anyone is interested...
I created a windows service in C# that monitors a socket. If a client connects to that socket the service gathers port name, and device id that is on that port and sends the data in a string over the com port the client can then parse apart the string to get the data it needs.
In my case the string being passed is:
"ACPI\PNP0501 *PNP0501 ,COM1 ,PCI\VEN_8086&DEV_29B7&SUBSYS_02111028&REV_02 PCI\VEN_8086&DEV_29B7&SUBSYS_02111028 PCI\VEN_8086&DEV_29B7&CC_070002 PCI\VEN_8086&DEV_29B7&CC_0700 ,COM3 ,USB\Vid_067b&Pid_2303&Rev_0400 USB\Vid_067b&Pid_2303 ,COM5"
When I parse it I can see that ACPI\PNP0501 *PNP0501 is the device id for COM 1, there are three device id's for COM3, and two device ids on COM5.
This may not be the best way to handle this but it is good enough for my needs and it saved me from JNI. :)
CommPortIdentifier.getPortIdentifiers lists all ports in the system that are usable by the Javacomm API. Iterate through them to find the port your device is connected to.
If you want to get the name associated with the device on the COM port (particularly if a driver is installed to provide it), you'll have to do so with a smidge of the dreaded Java->Native Interface to talk to the Windows APIs that gather this information. C# is nice, in that this information is gathered and provided to you, but in Java you have to go this extra step.
Windows Function Discovery may prove useful. I'm not certain exactly what API provides this functionality.