简体   繁体   中英

how to send messages using only IP address within LAN

I have two wifi modules that connects to my access point. my android phone connects to the same access point. Is there a way in Java to be able to send a message to any of the clients from my phone using just the IP address. I do not want to run a server on my phone.

I'll appreciate any assistance. Thanks

I feel there is a confusion about IP addresses and servers in general. An IP address is a way to find an entity on the network (it is an address). Since your phone is connected to the same access point, it is (very likely) on the same subnet. What that means is that it can talk to any of the other entities without going through a gateway, that is all.

While it is able to talk to them, there has still to be some entity listening. When your phone sends a message to a particular address (the other node on the network), the packet may make it there, but for the communication to proceed:

  • There has to be some listener on the other end that picks that incoming message
  • The communication has to follow a prescribed set of rules (protocol)

From what I gather, your phone is acting as the client, not the server. It initiates communication with the other entity on the network. Depending on which node on the network you are trying to talk to, that node is supposed to be expecting that communication and know how to carry it forward.

If you clarify the setup and your desire, may be you can get more to the point response.

What you were not understanding here is that you can send the message to that device with ip address but that data will not be shown on that device's screen because you didn't provided any port number for a process which is listening on that particular device. Your message will be sent but the device would not know what do with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM