Re: [gnet] Problems with GNet and GIOChannels...



On Thu, 2004-08-26 at 10:13, Michael Torrie wrote:
> On Wed, 2004-08-25 at 21:26, James Wiggs wrote:
> >    Thanks for your feedback on this.  I've implemented a solution based
> > on GServer/GConn as you and Tim both suggested.  I'm running into some
> > problems with it that have me more or less stumped.  There's one basic
> > question that I never even *thought* to ask, but perhaps I should.  All
> > of the example codes in the GNet distribution deal solely with ASCII
> > character data.  Can the sockets maintained by GNet handle *BINARY*
> > data or can they not?  I need to be able to pass any kind of data into
> > these sockets and have it come back out again at the other end, intact,
> > without killing my code in the process.
> 
> For what it's worth, I transmit binary data (the actually format of the
> data is ASN.1, which is a binary packing format) all the time through a
> GConn * socket.  So no, there's no inherent ASCII-only factor here.  The
> only catch is that socket traffic is not guaranteed to come all at once
> in distinct messages.  Sometimes you get 5 bytes, sometimes just 1. 
> That's why all data protocols include a header with a length field so
> you know exactly how many bytes to wait for (you have to keep looping on
> a read until you get them all).  Not sure that this has anything to do
> with your problem, though.
> 
> Michael

 Hi Michael,

   Well, I guess that's good news and bad news.  Good news in that
it says this is doable without hacking GNet, bad news in that I'm
going to have to find my bugs elsewhere.  About those comments on
the "partial" messages: isn't it the job of gnet_conn_readn() to
*wait* until it has all 'n' bytes you've requested *BEFORE* it
fires the GNET_CONN_READ signal?  I thought that was the whole
point of having a "_readn" function call!

   Do you explicitly free the data out of your GConnEvent structures
after reading it into your own variables?  Any problems with that? 
Are they using GChunks or something, where you should not free them
with g_free()?  I'm in the process of rewriting the code I sent last
night to try to simplify things as much as humanly possible, for a
first run.  Extend it to be more flexible later...

thanks,
Jim Wiggs





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]