hi

i wanted to inquire about two things. First, is it possible to connect two phones that both possess wireless cards to each other without there necessarily an access point, if so how could i, in theory, use it to design a messaging application in J2ME.

thanks

Dani AI

Generated

Short answer: yes in principle, but only if the phones support either an ad‑hoc (IBSS) Wi‑Fi network or a peer‑to‑peer Wi‑Fi mode (Wi‑Fi Direct), and the device firmware actually exposes IP networking to a MIDlet. asked if WAP-capable wireless cards can talk without an AP; correctly noted other P2P options (Bluetooth/IR), which remain the most portable choice for J2ME MIDlets.

Two technical routes exist for Wi‑Fi P2P:

  • legacy ad‑hoc (IBSS): both radios join the same ad‑hoc SSID and exchange IP packets; and
  • Wi‑Fi Direct (P2P): one device becomes group owner and clients join. See Wi‑Fi Alliance documentation on Wi‑Fi Direct (peer‑to‑peer). (https://www.wi-fi.org/discover-wi-fi/wi-fi-direct)

Important platform limits: J2ME / MIDP does not define APIs to change the Wi‑Fi radio mode. The MIDP Generic Connection Framework (Connector, DatagramConnection, SocketConnection) can open IP sockets if the device grants IP access to MIDlets (JSR‑118). If the firmware blocks ad‑hoc or does not expose Wi‑Fi Direct to Java apps, MIDlets cannot force a P2P link.

A minimal MIDlet approach when IP is available: open a UDP or TCP connection with the GCF and exchange messages.

DatagramConnection dc = (DatagramConnection) Connector.open("datagram://:5000");
Datagram dg = dc.newDatagram(256);
dc.receive(dg);
String msg = new String(dg.getData(), 0, dg.getLength());

or a TCP client:

SocketConnection sc = (SocketConnection) Connector.open("socket://192.168.1.10:6000");
InputStream in = sc.openInputStream();
OutputStream out = sc.openOutputStream();

Practical checklist: confirm device supports ad‑hoc or Wi‑Fi Direct (or create the ad‑hoc network in phone settings), confirm MIDlet network permissions/signing, test with fixed IPs on the same subnet, and have a Bluetooth (JSR‑82) fallback for phones that block Wi‑Fi P2P (see JSR‑82 and JSR‑118 details on jcp.org). (https://jcp.org/en/jsr/detail?id=82) (https://jcp.org/en/jsr/detail?id=118)

Recommended Answers

All 3 Replies

Not sure what you mean by "wireless cards" in mobile phones? There is plenty of examples for messaging done through Bluetooth or InfraRed, just google for it

hi

forgive me but i' m not that good with technical terms. but i meant phones wireless network cards that can access WAPs.

Can you give me an example of product manufactured by somebody? This way we can easily come to understanding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.