I looked at DataOutputStream and the only difference I saw was that
the doc said that it sends the data in big-endian format.  I'm not
sure if OutputStream is big-endian or little-endian, I think it's
little-endian.  DataOutputStream is inherited from OutputStream so
they should have the same functionality. Anyway, so your problem is
that you're not seeing anything on the other end(Server end).  I would
use some kind of network analyzer on the server end to see what's
coming in.  Another thing I'm not quite sure about is that you use
flush.  In my code, I don't use flush.  I just call
myoutputstream.write(aByteArray);

I see that this line:

dataout.write(bdata,0,bdata.length);

has length 0 because bdata is not set to any data.  The offset which
you have as 0 is fine but unless you are setting bdata to some value
or values, it won't write anything because the length is zero.
Otherwise it should write something to that socket.

If that is not all of your code maybe you can post more of it but if
thats all of it, that is what your issue is(bdata.length = 0).

On Mar 23, 8:27 pm, Honest <[email protected]> wrote:
> HI,
> Thanks for your reply. do you think there is any difference in
> OutputStream and DataOutputStream ?
>
> On Mar 24, 4:56 am, Wall-E <[email protected]> wrote:
>
>
>
>
>
>
>
> > Sorry, I failed to include that the out variable is an OutputStream
> > object. So,
>
> > OutputStream out;
>
> > is what I'm using.
>
> > On Mar 23, 3:23 am, Honest <[email protected]> wrote:
>
> > > 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to