Today I finalized my server for my Android app. Once again, involving socket.io. However, I came into the issue that each client needs a specific ID. So, after some thought, I made it such that each client listens from the socket only on a very specific ID event. That way, the client will only listen to information pertaining to what it needs to know, without having to listen to information from a lot of other sources.
I did it by assigning a listen event to a variable, like so:
socket.on(idVariable, eventFunction);
Then, the eventFunction would be called, and we could send and receive data from the server to the client.
I've never done network programming, but looking at the Wikipedia article here:
ReplyDeletehttp://en.wikipedia.org/wiki/Network_socket
Indicates that an Internet socket address is the combination of an IP address and a port number. Since only one application can listen on a given port, that would make the socket address unique to the given process on the given machine.
If you want to do this kind of programming effectively, an understanding of the theory behind it will be most helpful to you.