Messaging between two android devices

For messaging between two devices, a client and server thread was created. The application acts both as a server and a client. It does both opening a server socket and listening on it and opening a client socket and connecting to other device.

The server class initializes the server socket and starts accepting the connection. It also reads the message from the client side. The client thread creates a socket connection to a remote server. After the connection is made, it starts writing to the other side. 

The application starts with both emulators asking for the client port. When user enters the port number and presses the connect button, it assigns the port number to the instance. Similar way the second emulator asks for the port number to get connected. After the two emulators are connected, the messages can be interchanged.

Please comment below if you have any questions.

Comments

Popular posts from this blog

Difference between "diff" and "sdiff" commands in Unix

Anonymous classes in C++