Win a copy of Rust Web Development this week in the Other Languages forum!

Asif Kadiwala

Greenhorn
+ Follow
since Jun 10, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Asif Kadiwala

Hi all,

I want send requests and receive response between C# client application and java server application using Socket programmig (TCP).

I am not able to read the Buffer using readLine() method at the java server till the C# client closes the socket. The control hangs at
String receive = in. readLine(); line till C# client closes the socket..

The same thing I have tried with java client and java server and it works fine in this case..

Can anyone tell me what can be the problem.

Thanks in advance.
Asif
Hi all,

I am using reflection API method.invoke(object); to call that method dynamically from anther class ABC. This works fine till I define all the parametes in that method itself, which are being used in the method.

The prolem arises when I am using some variables which are defined outside that method (but in the same calss ABC) , it gives nullpointerException at that variable. Is there any way to solve this issue.

Thanks in advance.
12 years ago
Hi all,

I want to block the main thread(keeping) it alive till the another (b/g) thead completes its execution, I want this scenario because my futher operations in the main() thread depends on the results of the b/g tread. I used the wait() in the main thread and notify in the another but could not solve my problem.

public static void main(String[] str) {

xxxx
xxxx
Thread t;
wait();
yyyy;
yyyy;
}

here all "yyyy" depends on the result of Thread t. So I want to block the main thread there.

Is there any way to accomplish this?? Thanks in advance.


Regards,

Asif
Hi,

Please go through this discussion and let me know if any doubt.

http://www.anddev.org/socket_programming-t325.html
12 years ago
Hi,

After android 1.0 onwards, android is not providing any permission to access .apk files at the runtime. So Regarding android Hacking chapter, Is there any way to change that permission and call the .apk file at the runtime which resides in the /sdcard.

My aim is to transfer a .apk file from the desktop during the application execution , store it in the /sdcard and call it dynamically using PathClassLoader.

Thanks in advance.
12 years ago
Hi all,

Please tell me that any API is available or not.
12 years ago
Hi all,

Hi all,

I am storing the required test.jar file in the /sdcard. I want to
load it dynamically at runtime and want to execute a function xyz()
resides in that.

I had used typical java ClassLoader mechnism to execute it but fails and got Exception
ClassCastException : dalvik.system.PathClassLoader

My .jar file contains .class file. I think it should be converted to .dex file and then it can be used. But I want some proper information to execute my task. Please Help

Regards,

Asif
12 years ago
hi,

I had already tried with that, I had inserted "FEFF" at the start of the message but still getting same exception.

any idea???
Hi all,


I am using Java application as Socket server and C# application as Socket client. Server is listening at port 1800.

from the C# client when I m sending a String with UNicode encoding to java server then I am getting follwing error during convertting BufferedReader to String using readLine() methos : sun.io.MalformedInputException: Missing byte-order mark

SO my doubt is that, Is there any way to add Byte Order at C# client so that we can receive cleanly. In the ASCII case I can receive cleanly.

Follwing is the code snippet at the server ,

ServerSocket ss=new ServerSocket(1800);
Socket s=ss.accept();
System.out.println("Client Accepted");
BufferedReader br=new BufferedReader(new
InputStreamReader(s.getInputStream(),"UNICODE"));

String s1 = br.readLine(); // This line throws exception


Please help me ASAP. Thanks in advance
Hi Ed,

Thanks a lot for your help as well as your tip.

This example
also gives better understanding of network IO using socket communication. But this works fine if we send String messages but my requirement is to transfer files from desktop java application to android emulator. Still got same problem.

Please reply
12 years ago
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){

}
}


}
12 years ago
Hello,

Can you please tell me how to do port scan before network redirection???

I have not done port redirection , but I had used the same ports for socket communication between Android as client and Desktop as server.It works fine for me. I had released the ports after that.
12 years ago
Hi Mark,

In the Socket communication , android emulator as socket client working fine.

But if I configure emulator as Android server and desktop as socket client, then first requirement is to assign an IP address to this emulator instance,

for that I had tried to follow follwing steps to achieve n/w redir but could not succeed.

1). telnet localhost 5554 : works fine and emulator console opened
2). redir add tcp:4444:4444 - it fails to execute then I tried
3).redir tcp:4444:4444 but again the same problem.

So can you please tell me how to achieve IP of the emulator and redirect the ports?? Should I configure default IP 10.0.2.15 to emulator or it takes automatically?? If I have to configure then how??

Please help
12 years ago
Hi Mark,

Thanks for your reply. Is it possible to store files received using socket communication from desktop to the emulator other than SD card?? How much memory emulator has??

For the socket communication, is there any API available to send files??
12 years ago
Can we create two way socket communication for file transfer?? Means Transferring files from Desktop PC to Android device and vice versa. And Is it possible to store the files in the device other than SD card???
12 years ago