• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SMS Application

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I'm creating an SMS application ( It's not a real SMS system , it will work with computers which they can send to each other short messages through server )
where
- The client will type the message ( doesn't exceed 160 ) and the recipient client IP address
- The client will send through the server
- A server receives messages from clients, stores them, and forwards them when the recipient client is connected

The problem :
Client :

1/ How to send the recipient client IP to server ?
In sendPacket , the IPAddress will be server address ( client send through the server ) , I also need to put the receiver IP somewhere where server will forward the msg to recipient client
but I didn't know where to put it


Server :
1/How multiple client can connect with the server ?
I read about the threads but I didn't know where to put it

2/ How the server check if reciever is connected ? I found this code but I'm not sure about it


I found about method Reachable but for some reason it always return false

Here the complete code
Client


Server :


Thank you and I hope you help me

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the server is a Java web app, and your app will run on the sending and receiving cell phones? Since I see Java code for the "client", is this supposed to be a JME or an Android app?

But regardless, I very much doubt that it can work this way, or rather, that the receiving of messages can work this way. Although mobile devices do have an IP address, mobile networks do not generally route incoming IP traffic from arbitrary hosts (like your server) to the devices. An alternative might be to use telephony alternatives for hailing the device, like GCM for Android devices (iOS has something similar). Then the app on the receiving phone can contact the server and retrieve the message,

How multiple client can connect with the server ?


If this is a servlet-based web app, then the concurrency is handled by the servlet container. Just make sure your servlet code is thread-safe.
 
Arwa Saad
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So the server is a Java web app, and your app will run on the sending and receiving cell phones? Since I see Java code for the "client", is this supposed to be a JME or an Android app?



No , the server is not web and my app will work on computers
I forget to mention it but it's not like a real " SMS " system . it's like computers can send to each other short messages through server

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. You will most likely still run into the problem of the server not being able to contact the receiving machine (unless they're both on the same network).

If you somehow manage to overcome that, the usual approach to finding the IP of the receiver is to have the receiver check in with the server when the app on the receiving machine starts up. Then the server will have the IP (along with some ID that the receiver had better send, so that the server knows which client/user is running on that machine).
 
Arwa Saad
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I see. You will most likely still run into the problem of the server not being able to contact the receiving machine (unless they're both on the same network).

If you somehow manage to overcome that, the usual approach to finding the IP of the receiver is to have the receiver check in with the server when the app on the receiving machine starts up. Then the server will have the IP (along with some ID that the receiver had better send, so that the server knows which client/user is running on that machine).



Yes , they are on the same network
also , I manged to get reciver ip by making the sender send it along with the message .

Thank you

----

I still have problem with the following


1/How multiple client can connect with the server ?
I read about the threads but I didn't know where to put it

2/ How the server check if reciever is connected ?



anyone ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For #1, read http://docs.oracle.com/javase/tutorial/networking/sockets/index.html, particularly about the client/server pair. It talks about how the server can support multiple clients simultaneously.

As to #2, the server can just try to connect to the last-known IP of a client. If the connection fails, the client is no longer online.
reply
    Bookmark Topic Watch Topic
  • New Topic