0

I have a client-server program in java.. I need to handle in 2 scenarios:

  1. The client send messages to the server and the server processes the message and return the result. (this works fine)

  2. When something happens at the server I need to send the data to the client to process it.

To be more specific on the second scenario, I'm trying to develop an android app, so when I'm getting a text messages (SMS) it sends to my PC the sender data and the message body. I'm doing this by using the WIFI network (just for fun :) )

Any ideas? I thought about to have a thread in my client side (PC) to listen the server messages.. but I don't think its a good solution..

Elior
  • 3,178
  • 6
  • 37
  • 67
  • You need to look up socket connections and how Java handles them. Good start here: http://docs.oracle.com/javase/tutorial/networking/ – Chris Chambers Apr 27 '13 at 17:50

2 Answers2

1

http://www.java-samples.com/showtutorial.php?tutorialid=22

A good place to start and indeed a client thread is a possible solution.

You can also check with node.js non blocking client server interactions. http://blog.smsified.com/tag/node-js/

rozar
  • 1,058
  • 3
  • 15
  • 28
0

You need a asynctask to handle the incoming data and to create the socket on its own

I had did something very like what your trying to and this is what solved my problem

My Solution to my own Problem and it works

And the same needs to happen on your server just make sure not to close the sockets

Community
  • 1
  • 1