Wednesday, March 23, 2011

[android-developers] Sending data from android apps to TCP IP

Hello,

I am able to connect to TCP IP netwrok but even if i am sending some
byte array but yet i am not seeing any output on Server console.
Server is C++ and i need to send data from my android apps. I am able
to connect but when i send data i am not getting any notification. the
followins is my code.

InetAddress serverAddr = InetAddress.getByName(serverIP);
SocketAddress socketadd= new InetSocketAddress(serverAddr,
serverPort);
Log.d("TCP", "C: Connecting...");


//Socket socket = new Socket(serverAddr, serverPort);
Socket socket=new Socket();

try {
Log.d("TCP", "C: Sending: '" + msg + "'");
socket.connect(socketadd);
Log.e("Connect:", "Connect:");
DataOutputStream dataout = new
DataOutputStream(socket.getOutputStream());
dataout.flush();

byte haeader[]=new byte[6];
// String data="20110110,cswxerotest,cswxerotest";
// Packet p=new Packet();
//byte bdata[]=converttoCPP(getBytes());

byte bdata[]=getBytes();
//byte a[]=new byte[20];

//dataout.writeByte(5);
dataout.write(bdata,0,bdata.length);
dataout.flush();

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate