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



On Sat, 2004-08-21 at 11:04, Andrewlanoix aol com wrote:
> I will comment on the underlying problem:
> 
> 1) I always recommend that you use the newest release and try the version in CVS. We you may be running into a bug we already fixed.
> 2) I would recommend that you try GConn as Tim suggested.
> 3) I would recommend that you verify that your ref counting on your objects is correct. To do this, put print statements in glib (giounix.c and perhaps gmain.c) and in the gnet code. I find this is a huge problem. Have them print out the ref count and what function was called. I found this to be very usefully with debugging glib itself.
> 4)  I would recommend that you put break points where you put the print statements, take a break yourself and then come back and debugger should break to right place in glib, which you then can walk through glib, gnet and then your code. 
> 
> To answer your questions:
> 1) G_IO_IN and then a read of 0 bytes, or a G_IO_* error condition.
> 2) No.
> 3) See my suggestions above.
> 
> Andrew
> 

 Andrew,

   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.

   That said, I have some code snippets to pass along to see if anyone
can spot something obviously wrong.  Here's some structure definitions:

typedef struct _ServerProcess {
	gchar			Name[32];
	GInetAddr		*IpAddr;
	gint			Port;
	GServer			*Server;
	GServerFunc		(*ConnFunc)();
	GThread			*Thread;
	GAsyncQueue		*Queue;
	GMainContext	*Context;
	GMainLoop		*MainLoop;
	GTree			*ClientTree;
	GMutex			*ClientTreeMutex;
	gint			ref_count;
} ServerProcess;

typedef struct _ClientProcess {
	gchar			Name[32];
	GInetAddr		*IpAddr;
	gint			Port;
	guint			UniqueID;
	gint			PermOrTemp;
	gint			IncomingOrOutgoing;
	ServerProcess	*ServerProc;
	GServer			*Server;
	GConn			*Connect;
	GConnFunc		(*CallbackFunc)();
	GThread			*Thread;
	GAsyncQueue 	*Queue;
	GMainContext 	*Context;
	GMainLoop		*MainLoop;
	GQueue			*IncomingData;
	GQueue			*OutgoingData;
	gint			waitingForMessage;
	gint			waitingForPayload;
	gint			waitingForHeader;
	NetworkMessage	*IncomingMessage;
	gint			ref_count;
} ClientProcess;


typedef struct _NetworkMessageHeader {
	guchar			SOHByte;
	guchar			HeaderSizeByte;
	NetworkMsgType	MsgType;
	gsize			MsgSize;
	guint			UniqueID;
	guchar			EOHByte1;
	guchar			EOHByte2;
} NetworkMessageHeader;


typedef struct _NetworkMessage {
	guchar			SOHByte;
	guchar			HeaderSizeByte;
	NetworkMsgType	MsgType;
	gsize			MsgSize;
	guint			UniqueID;
	guchar			EOHByte1;
	guchar			EOHByte2;
	gpointer		MsgData;
} NetworkMessage;




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