Java Network Events

I am creating a java mobile application and I want to be aware as to when the device obtain an IP address to then be able to send messages to a backend system.

Do any API exists? I guess if an API existed it would have to use system dependant calls thru JNI?

Thank you, Julien.

Asked by: Elise845 | Posted: 28-01-2022

Answer 1

OK, I'm not 100% sure I understand what you are trying to do but here are a few things that could prove useful:

  • stackoverflow has tags for J2ME and javaME, the mobile versions of Java.

  • Theorically, installing a MIDlet that declares a static PushRegistry socket connection could force the device to always have an IP address. That would obviously depend on how the Pushregistry spec was interpreted by the VM provider.

  • There is no standard JNI support for mobile Java virtual machines.

  • A mobile Java application may be automatically paused when it is backgrounded so I'm not convinced you shouldn't just use the GCF API to open a client socket connection to your back-end system. It is presumably only needed when the MIDlet is in the foreground.

Answered by: Lydia252 | Posted: 01-03-2022

Similar questions

networking - Simple Network chat in Java

just had a question to a simple chat program i wrote in java. The program uses TCP to transmit simple message strings back and forth from Server/Client. And it works on all the computers on my Network. But when i sent it to a friend of mine to see if it worked from his computer it did not. So my question is: Would i need to add some specific code to allow messages from other comps from outside my network to be recieved? or...

networking - Java: trying to send a bunch of information over a network

Okay, I've been working on this for days now and I can't find any information anywhere. I made a simple game that works pretty well, but I wanted to add two-player functionality. I've already established a connection to another computer over LAN, but I have no idea how I'd send the data. I understand writing to ObjectOutputStream's, but how do I get the other side to interpret it? Do I send each variable separately? As of ...

networking - Send PDF file to network printer in Java

I'm trying to send a PDF/DOC/ODT file to a printer connected in LAN using javax.print, but it doesn't even send the job to the print queue. I've tried to print the file "normally" (using Adobe Reader /Open Office) and works perfectly, so the printer is well connected. I've also tried to send it to a virtual printer (PDFCreator) from code and it worked. Here is the code I'm using: public Boolean Impr...

networking - Java network game design

I am designing a simple chess game in java and want to add network(client and server model) to to it. One player is on server side and the other on client side. Right now I hava a and is included in both server side and client side(each player has a game instance). My problem is that I don't know when to send data between two sides. I add listener to the game class b...

networking - Network packet capture in Java without libpcap

I was wondering if there are any libraries useful for network packet capture and analysis that do not build off of libpcap? I'm trying to develop a platform-independent application. Thanks

networking - How to get IP's of all network devices in Java

I'm working on a project, and basically I need this program to find a list of all connected IP addresses to a network, such as going to your network connections in Windows. I've looked all over the internet, and I cant find what I'm looking for and I hope someone can! This program cannot just crunch numbers (such as pinging all possible IP addresses), it needs to be faster than that. Being able to just connect to t...

networking - How to find network type in java

NetworkInterface provides a list of available interfaces on a device. How do I find out the type of internet interface(Ethernet / Wifi). For example ConnectivityManager in Android allows to check for connection type. I have tried going through ifconfig information to find out the network type, but it doesn't seems to work. Assuming en0 and en1 to be ...

networking - Java network client sends only one message

I am learning Java and I'm writing an example client - server application. The sokcket connection is fine, everything works well until the second message from the client app. It does not reach the server. If I start another client it also succeed at the first message, and fails at the second. Anyone has an idea? Thanks in advance!

networking - Java network metric

I try to check the IP of a hostname. I have two network devices, "A" has metric 1 "B" has metric 2 My hostname is develop. I have a Webserver listening at only. (Metric 2) How to specify to use metric 2 using the hostname but not the IP-Address?

What are the best Java social networking frameworks?

networking - Java printing directly to a Postscript network printer

I've got Postscript code/data (?) in memory (in a Java Tomcat webapp) that I'd like to send directly to a networked PS printer. Is there an easy way (i.e. just popping open a port and sending the text) to print this, bypassing all of the O/S-specific drivers and stuff (and hopefully not even requiring extra jars)? A link to example code showing how to do this? Thanks, Dave

networking - Is it possible to create a Java UDP Socket to listen on all addresses?

I would like to have a single DatagramSocket to listen for both unicast and broadcast messages. Is this possible?

networking - Disable character echo on Java network connection

I have a Solaris daemon written in Java6. Clients can connect to it using a telnet style interface. They telnet to a particular port, and I read lines of input and act on them. At one point in I need to prompt the user to enter a password, and while they're entering that I want to disable the echoing of characters back to the telnet client. The code has a Socket object and creates an InputStream from the so...

Is there a good Java networking library?

Closed. This question does not meet Stack Overflow guid...

networking - Java RMI Resources

I am currently undertaking a project that involves extensive use of Java RMI and I was wondering if anyone is aware of any good resources about it. The problem I am having with the material I am finding currently is that its usually quite out of date (like Java 1.3) and / or half complete. I would even be happy to buy a book on it but looking on Amazon all the books are like 7 years old. So if anyone is aw...

networking - Java NIO: Sending large messages quickly leads to truncated packets and data loss

I've got this nasty problem where sending multiple, large messages in quick succession from a Java (NIO) server (running Linux) to a client will lead to truncated packets. The messages have to be large and sent very rapidly for the problem to occur. Here's basically what my code is doing (not actual code, but more-or-less what's happening): //-- setup stuff: -- Charset charset = Charset.forName("UTF-8"); ...

networking - Determine remote client IP address for Java RMI call

When I implement an RMI server (implement an interface that extends java.rmi.Remote) is there a way to get information about the current RMI request context, specifically the remote client's IP address? public void myMethod() throws RemoteException {"remote IP is "+ RMISomething.getSomething()); }

networking - Connecting to a CDMA network IN from Java

Am using java to develop program that receives and processes SMS messages. I have been able to code the processing of the SMS Messages received and its working perfectly. Now the challenge i have is receiving the the SMS Messages from the CDMA network. When the application is about to go live, the CDMA network will setup a VPN connection which will enable my application to connect to its IN or its IN connect to my applicat...

networking - Why am I getting an error when I try to run my socket program in Java?

I'm using jcreatorLE and JDK 1.6 to run my program. I don't know why I get an error when I try to run. Could somebody explain the reason to me? This is the code for the Server: import*; import*; class ServidorTCP { // variable to wait for connections private static ServerSocket servidor = null; // Variable to process client connections private static...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)