[android-developers] Re: Re: Packing data onto socket stream ?
If you're doing web dev and don't know about json, you're probably doing something wrong. Anyway, good luck with your odd approach. OK, OK, I shall look at it. May be it can simplify some of my tasks. You see there are always so many things to look into it that ends up looking a few things only. Java alone has so large a library it will probably take quite a while to get acquited with them, or at least read them very quickly just leave an impression. I have done a lot of C/C++, even then there are areas that I think are hair-raising. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- 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
[android-developers] Re: Re: Packing data onto socket stream ?
Well, now it sounds like you're reinventing mime types..., but this isn't a horrible way to do it either I suppose. In either case what's giving you the difficulty? You can send the bytestream by doing a standard read() and write() across the socket, so this shouldn't be too bad.. Thanks. I am pretty new with Java (I have written no more than 2 programs, all from tutorial). I think there are pretty large gap in my knowledge. Only yesterday I discovered that a JTextArea object can be passed to another class; I have not come across this before. In C/C++ this is pretty normal with the use of pointer. Given a memory buffers (pointer), one can cast a length of bytes (from an offset) to a data type. Since you mention bytestream, I assume that I can use the format abytestream bb[i] to read the data. I shall test it out anyway. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- 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
Re: [android-developers] Re: Re: Packing data onto socket stream ?
Does it have to be a binary format? These days, it's common to use text-based formats even if it's somewhat less efficient -- to simplify development, debugging and later, maintenance and enhancements. -- Kostya 30 декабря 2011 г. 17:29 пользователь SL@maxis ecp_...@my-rialto.comнаписал: Well, now it sounds like you're reinventing mime types..., but this isn't a horrible way to do it either I suppose. In either case what's giving you the difficulty? You can send the bytestream by doing a standard read() and write() across the socket, so this shouldn't be too bad.. Thanks. I am pretty new with Java (I have written no more than 2 programs, all from tutorial). I think there are pretty large gap in my knowledge. Only yesterday I discovered that a JTextArea object can be passed to another class; I have not come across this before. In C/C++ this is pretty normal with the use of pointer. Given a memory buffers (pointer), one can cast a length of bytes (from an offset) to a data type. Since you mention bytestream, I assume that I can use the format abytestream bb[i] to read the data. I shall test it out anyway. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- 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.comandroid-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+**unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=en -- 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
[android-developers] Re: Re: Packing data onto socket stream ?
xxxThis is a greeting. where: xxx - message type (3 bytes, text) - integer, 4 bytes, length of text 'This is a greeting.' - the actual text There's no reason to use the NDK for this, The standard Java socket API can be used for this easily: http://docs.oracle.com/javase/tutorial/networking/sockets/ I am not sure, for example, how to retrieve the integer portion (ie 4 bytes); any problem with Endian oddities ? Just thinking, can I use an object, serializable one ? Thanks. -- Using Opera's revolutionary email client: http://www.opera.com/mail/ -- 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
Re: [android-developers] Re: Re: Packing data onto socket stream ?
On Fri, Dec 30, 2011 at 5:36 PM, SL ecp_...@my-rialto.com wrote: xxxThis is a greeting. where: xxx - message type (3 bytes, text) - integer, 4 bytes, length of text 'This is a greeting.' - the actual text There's no reason to use the NDK for this, The standard Java socket API can be used for this easily: http://docs.oracle.com/javase/tutorial/networking/sockets/ I am not sure, for example, how to retrieve the integer portion (ie 4 bytes); any problem with Endian oddities ? Just thinking, can I use an object, serializable one ? Thanks. I think you're making this way too complicated. Endianness aside, why are you even sending the message length unless you are conforming to some protocol... You seem to be trying to reinvent the lower level tcp/ip layers. Why not just send your message and read the number of bytes it is? If you're using a buffered stream this shouldn't be an issue, you might only need something like this if you had udp and you were trying to put assurance on top of it.. And sure, you can use a serializable object, but like I said, there's not really any need to.. If you go read that tutorial, especially the last client /server example, I think you'll find that yours is a common problem.. What are you using this for anyway? If you go through some basic examples in java sockets, this is a very basic problem you'd encounter as a first project in any networks class, so it shouldn't be too hard to learn given a few hours working through the tutorials. kris -- 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