hello socket programming tcp and udp l.
Skip this Video
Loading SlideShow in 5 Seconds..
Android Introduction PowerPoint Presentation
Download Presentation
Android Introduction

Loading in 2 Seconds...

play fullscreen
1 / 6

Android Introduction - PowerPoint PPT Presentation

  • Uploaded on

Hello Socket Programming. TCP and UDP @2010 Mihail L. Sichitiu. 2. Goal ... Programming Project to Android. Text input from the user sent to the same server(s) as ...

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Android Introduction' - Kelvin_Ajay

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
hello socket programming tcp and udp
@2010 Mihail L. Sichitiu

Hello Socket Programming


Android Introduction
@2010 Mihail L. SichitiuGoal

Convert the Java Socket Programming Project to Android

Text input from the user – sent to the same server(s) as before

Answer from the server(s)

Sends the input from the user to the UPD Server

Sends the input from the user to the TCP Server

@2010 Mihail L. SichitiuLayout

Create a simple layout that will include the required elements:




Register one “OnClickedListener()” for each of the buttons

Test functionality (make a toast for each listener)

socket programming
@2010 Mihail L. SichitiuSocket Programming

Define most variables as members of the main Activity Class


DatagramSocket clientSocket -> DatagramSocket udpClientSocket

Socket clientSocket -> Socket tcpSocket;

Adapt the code from pure Java to Android (especially the input and output strings) by filling in the two OnClickListeners

handling exceptions
@2010 Mihail L. SichitiuHandling Exceptions

Many network operations throw exceptions (as they can fail). In the original code they were just thrown out of main – in Android we have to handle them!


Operations that may fail and throw an exception;

}catch (Exception e) {

Log.e(TAG,"Caught UDP Exception: “ + e.getMessage());

Toast.makeText(HelloNets.this, "UDP Error"+ e.getMessage()), Toast.LENGTH_LONG).show();


running it
@2010 Mihail L. SichitiuRunning it

First give the application INTERNET permissions (like in the WebView)

Implement the UDP and TCP functionality separately

Run and debug.