thanks for your detailed explanation. I'm also interested in that topic. My question is that should the client be always connected to server via socket or establish that connection periodically to ask if there is new data? for example when we write something using whatsup, the receiver is informed immediately. it makes me think that there is always connection between client and server. am i wrong? of course I will search on Google about that issue but i would be really helpful if someone could provide some links concerning design patterns of that client-server architecture via socket.
thanks in advance Ferdi On 10 Temmuz, 21:05, Nobu Games <[email protected]> wrote: > Sockets can be used on networks for two-way communication between two > machines. It's a really raw and low-level kind of communication where you > have an input stream for reading what the other machine has to "tell" you > and an output stream for "telling" something the other machine. > > You need to come up with a communication protocol for getting something > useful out of such a connection. That usually works like that: > > You have a so-called socket server. It's a piece of software that waits for > incoming connection requests from clients and it also usually resides on a > server machine. The socket server listens to a certain port number of a > network address. That network address and port number needs to be addressed > by the client, when it wants to talk to the socket server. > > After a connection has been established some kind of negotiation between > client and server needs to happen. Your client app could for example send > some authentication credentials in order to log in the user. The server > sends some acknowledgment on success or an error message as response. > > If the login was successful your server could for example directly tell the > client that there are new messages available. > > I suggest > readinghttp://docs.oracle.com/javase/tutorial/networking/sockets/index.htmlfor > an > introduction to the Java side of it. > > I also strongly suggest that you are making use of secure sockets since you > are dealing with sensitive data (private conversations, login data). That > shouldn't go over the net unencrypted. Here is some documentation about > that:http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/J... > > It is also possible to create a socket server in PHP. But out of experience > it is not completely suitable for that task. First of all you need to turn > off the execution timeout for that socket server script (since PHP is meant > to be executed in terms of short-lived HTTP requests). Second of all PHP is > not reliable when run for a longer time. I tried to do that in the past and > it was a huge mistake. The garbage collector has serious problems and after > an hour or so, your script will terminate. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

