Hi all, The is working fine if I use this Socket server also as Desktop application. But it creates a problem at FIleOutputStream in the android application.
Please reply On Mar 10, 10:13 am, Asif k <asifk1...@gmail.com> wrote: > Hi all, > > I am running android server application which is listening to port > 4444 to retreive the file.I want to receive the file sent from Desktop > socket client application. To perform this task I used following code > as Android socket server. But execution stops infinitely at the > > bos = new BufferedOutputStream(new FileOutputStream("123.txt")); line, > Please help me to find out problem. > > FTPServer.java is as follows, > > import java.io.BufferedInputStream; > import java.io.BufferedOutputStream; > import java.io.FileOutputStream; > import java.io.IOException; > import java.io.OutputStreamWriter; > import java.net.ServerSocket; > import java.net.Socket; > > import android.util.Log; > > public class FTPServer implements Runnable{ > > ServerSocket server; > Socket connection; > > BufferedInputStream bis; > BufferedOutputStream bos; > > byte[] receivedData; > int in; > > public void run(){ > try { > server = new ServerSocket(4444 ); > Log.d("TCP..","FTP started..."); > try { > > while ( true ) { > connection = server.accept(); > > Log.w( "TCP","S:: receiving file... " ); > > receivedData = new byte[8192]; > Log.d("hello:","databye done"); > > bis = new BufferedInputStream(connection.getInputStream()); > Log.d("hello:","buffer input done"); > > bos = new BufferedOutputStream(new FileOutputStream("123.txt")); // > this line creates the problem > Log.d("hello:","buffer output done"); > while ((in = bis.read(receivedData)) != -1){ > bos.write(receivedData,0,in);} > > bos.close(); > > Log.w("TCP","File Received..... " );} > } > > catch (IOException e ) { } > > finally { > > } > } > > catch(Exception e){ > > > > } > } > }- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---