Become an Android app developer in the comfort of your own home! Really? ... Development for Beginners free ebook sites
Cheap Wifi Plug Power Socket Wireless App Remote Co ... Us Style White Free Shipping & Wholesale Price.pdf. Cheap Wi
Cheap Original Xiaomi Smart Socket Wifi App Wireless ... r For Android Ios Free Shipping & Wholesale Price.pdf. Chea
Cheap Phone App Control Wireless Timer Socket Mini S ... Power Wifi Plug Free Shipping & Wholesale Price.pdf. Cheap
Interface. Socket API. • Socket API. – Network programming interface. Socket. API
. TCP. UDP. IP ... Windows Winsock, BSD, OS X, Linux, Solaris, … – Socket ...
Development For Beginners: (Learn How To Program Android Apps, How To .... Applications Through Java Programming, Androi
Netbeans (opensource). □ Eclipse (opensource). □ BlueJ (designed for
introductory teaching, opensource). □ IntelliJ (payware, but those who use it say
it is ...
Aggiornamento di TomTom App for Android . .... Spostamento nella
visualizzazione di guida . ... Come tornare alla Visualizzazione di guida .
Become an Android app developer in the comfort of your own home! ... Programming and App Development for Beginners read ebooks on windows 10 Android: ...
Keywords: sockets, client-server, network programming-socket functions, OSI ...
In Linux, sockets and file descriptors also share the same file descriptor table.
Socket Programming. Kameswari ... In Unix jargon, a socket is a file descriptor –
an ..... Unix Network Programming, volumes 1-2 by W. Richard Stevens.
Jim Kurose, Keith Ross. Addison- ... J.F Kurose and K.W. Ross, All Rights
Reserved. 192.168.23.100:143 web server ... E.g. All port 80 request go the web
server.
In Unix jargon, a socket is a file descriptor – an integer ... Types of Sockets:
Internet Sockets, unix sockets, .... Unix Network Programming, volumes 1-2 by W.
Please refer to Richard Stevens book : “Unix. Network Programming” Volume 1
for details about any of the functions covered here, and also use the online man ...
The core package java.net contains a number of classes that allow programmers
to carry out network programming. – ContentHandler. – DatagramPacket.
EZCast WiFi Display Adapter Instruction Manual for Android ... Visonicom EZCast
WiFi display adapters support Android (Android smart phone and tablet PC), iOS
(iPhone and iPad), Windows (Windows ..... Samsung Galaxy 4. Android4.2.2.
Cheap Koogeek Wifi Smart Socket Plug Remote For App ... on Smart Outlet Free Shipping & Wholesale Price.pdf. Cheap K
Nor can I forget the heroes behind the scenes: copyeditor Luann Rouff and ..... All
the examples in this book run on the Android emulator (which is included as ....
Media support — Includes support for the following media: H.263, H.264 (in 3GP
or
AutoWatch® Android™ App pg. 2. User's Guide. AutoWatch Android Application.
Phone Setup. In order to download and install the AutoWatch Android App, ...
10 Apr 2013 ... My Grammar Lab A1/A2. Pearson Education Ltd. Education. My Grammar Lab B1
/B2. Pearson Education Ltd. Education. My Grammar Lab C1/ ...
Seagate Media App - Android. Welcome. The media app helps you to ... The media app supports a wide range of storage devi
The Dash Explorer Android App is designed to be a mobile information hub for DASH interested user. The first release sco
Sep 20, 2017 - 10 Updating the Seagate Media App and the Storage Device .... Download and install the free Seagate Media
research project describes the need and development of an Android application
that ... The App Inventor is a browser-based Android development environment ...
Jun 2, 2016 - In this project, we wish to develop and android application that en- ables two users to transmit and receive text via WiFi through socket.
SOCKET PROGRAMMING W I F I C H AT A P P F O R ANDROID SMARTPHONE Abby P Joby B130373EC
June 2, 2016
contents 1 2
3 4
Introduction Program code 2.1 Java Code - Back end . . . . . . . . . . . . 2.1.1 Server - socket program . . . . . . 2.1.2 Client socket program . . . . . . . 2.2 XML Code - front end . . . . . . . . . . . 2.2.1 Server XML code . . . . . . . . . . 2.2.2 Client XML code . . . . . . . . . . 2.3 Putting It Together . . . . . . . . . . . . . 2.3.1 Java code for the Server Program . 2.3.2 Java code for the Client Program . App in action Future possibilities
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
2 2 2 4 5 6 6 8 10 10 13 16 17
The Android Studio IDE . . . . . . . . . XML design window . . . . . . . . . . . . Server GUI corresponding to above code Client GUI corresponding to above code . Server app . . . . . . . . . . . . . . . . . . Client app . . . . . . . . . . . . . . . . . . Server shows status . . . . . . . . . . . . . Chat history in client . . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
2 6 7 9 16 16 16 16
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
list of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8
1
introduction
1
introduction
In this project, we wish to develop and android application that enables two users to transmit and receive text via WiFi through socket programming. We have chosen to implement this project on android smart-phones. The primary programming language used in developing android apps is Java. All the back end functions and the socket programming is implemented in Java. The user interface ie front end is implemented using XML (Extensible Markup Language) and both the back end and front end are connected together in the Java program. We have used the Android Studio IDE (similar to eclipse IDE) to program the app.
Figure 1: The Android Studio IDE
2
program code
2.1 Java Code - Back end Every android app is divided into three sections. These three sections interact with each other through the code to complete the entire app. • Java code • XML code • Android manifest First let’s look at the Java code. For this project, we had to create two applications one for the server and another for the client. Both these apps were running on two different smart-phones. The Java code of most android apps start with a method called onCreate(). This method defines the initial setup of all the variables and the various elements in the application. We can use this section to setup the
2
program code
3
buttons and define what will happen when the button is pressed. It is also used to link the element of the front end with the back end. For eg, the graphic front end element Button is linked to the Java code through this method. Similarly other elements are also linked. protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_server); wmanager = (WifiManager) getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wmanager.getConnectionInfo().getIpAddress()); smessage = (EditText) findViewById(R.id.smessage); chat = (TextView) findViewById(R.id.chat); display_status = (TextView) findViewById(R.id.display_status); display_status.setText("Server hosted on " + ip); Thread serverThread = new Thread(new serverThread()); serverThread.start(); button_sent = (Button) findViewById(R.id.button_sent); button_sent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Thread sentThread = new Thread(new sentMessage()); sentThread.start(); } }); }
The above is the onCreate() method used in the server application. A similar method is used in the Client application also. The server application will display its IP address to which the client can connect. The port number has been predefined as 10000. Both the applications run two threads. One is used to scan for incoming messages and the other is used to send messages.
program code 2.1.1 Server - socket program A socket is an endpoint of a two-way communication link between two programs running on the network. Socket is bound to a port number. There are basically 5 steps to create a server program in Java. Since android apps are developed using Java, the same procedures apply here also. • Open server socket • Wait for client request • Create I/O stream for communication • Perform communication • Close socket A server program creates a specific type of socket that is used to listen for client requests (server socket). In the case of a connection request, the program creates a new socket through which it will exchange data with the client using input and output streams. The socket abstraction is very similar to the file concept: developers have to open a socket, perform I/O, and close it. // first open a socket in the server ServerSocket serverSocket = new ServerSocket(port_number);
// next, wait for the client to connect Socket client = server.accept();
// create I/O streams for communication DataInputStream is; DataOutputStream os; is = new DataInputStream(client.getInputStream()); os = new DataOutputStream(client.getOutputStream());
// perform communication // To receive from client: String line = is.readLine(); // To send to client: os.writeBytes();
// close the client socket client.close();
We have implemented the Server program with two threads. One thread is called inside the onCreate method and it continuously monitors the input stream for incoming message. The second thread runs whenever the button is pressed. This is used to write data to the output stream.
4
program code 2.1.2 Client socket program The steps involve in creating a client program is very similar to that of the server program. • Open socket • Create I/O stream for communication • Perform communication • Close socket // first open a socket in the server Socket socket = new Socket(server_ip , port_number);
// create I/O streams for communication DataInputStream is; DataOutputStream os; is = new DataInputStream(client.getInputStream()); os = new DataOutputStream(client.getOutputStream());
// perform communication // To receive from client: String line = is.readLine(); // To send to client: os.writeBytes();
// close the client socket socket.close();
5
program code 2.2 XML Code - front end The front end of the application was designed in Android Studio IDE using XML (Extensible Markup Language). The Server and client apps are designed in different manners. The server application has just one button and one text field to input text. The client application has two buttons one to facilitate the connection and one to sent messages. It also has two text fields, one to input the IP address of the server and another to input the message to be sent.
Figure 2: XML design window
2.2.1 Server XML code
Figure 3: Server GUI corresponding to above code
7
program code 2.2.2 Client XML code
8
program code
Figure 4: Client GUI corresponding to above code
9
program code
10
2.3 Putting It Together 2.3.1 Java code for the Server Program package com.example.abby.server; import import import import import import import import import
public class ClientThread implements Runnable { public void run() { try { while(true) { InetAddress serverAddr = InetAddress.getByName(serverIpAddress);
14
program code Socket socket = new Socket(serverAddr, 10000); // create client socket /******************************************* setup i/p streams ******************************************/ DataInputStream in = new DataInputStream(socket.getInputStream()); String line = null; while ((line = in.readLine()) != null) { msg = msg + "Server : " + line + "\n"; handler.post(new Runnable() { @Override public void run() { chat.setText(msg); } }); } in.close(); socket.close(); Thread.sleep(100); } } catch (Exception e) {} } } }
15
app in action
3
app in action
First, we ensure that both the smart-phones are connected to the same WiFi network. Next open the client and server apps on different phones. The server app will show its own IP address. This IP address is given to the client app. On clicking the connect button, a connection is established between the client and Server and we are now ready to transfer information. The below pictures describe the complete process in work.
Figure 5: Server app
Figure 6: Client app
Once the IP address shown in the server app is entered into the client app, click on the connect button.
Figure 7: Server shows status
Figure 8: Chat history in client
Once the connection is established, we can move on to the task of sending data. The user can input text in the provide space and click on the button sent. The message will be updated in the chat history and all the messages are displayed in the screen.
16
future possibilities
4
future possibilities
This basic application could be later extended to facilitate a wider network. Thus we can conclude that this application would form the base of some of the popular applications such as Whatsapp and Snapchat. We could also use this method to establish communication between wifi enabled sensor networks and an android smartphone thereby facilitating the Internet Of Things.