Example #1
0
/*
 * Generic mux interface callback functions
 * _lms_socket_default_read() = read condition from mux
 *
 * fd = file descriptor
 * e = event type
 * msoptr = pointer to the MSocket object on which the mux found something for us
 *
 */
void _lms_mux_default_read(int fd, short e, void *msoptr)
{
	MSocket *mso;

	if (msoptr)
	{
		mso = (MSocket *)msoptr;
	}
	else if (fd >= 0)
	{
		mso = lms_socket_findbyfd(fd);
	}
	else
	{
		/* mux is going a lot batty */
		return;
	}
	if (!mso)
	{
		/* mux is going a little batty */
		return;
	}

	if ((mso->type == LMSTYPE_LISTEN4) || (mso->type == LMSTYPE_LISTEN6))
	{
		lms_conn_accept(mso);
	}
	else if ((mso->type == LMSTYPE_STREAM4) || (mso->type == LMSTYPE_STREAM6))
	{
		/* Allows us to differentiate between an SSL connection and a non-SSL connection... */
		mso->func_r(mso);
	}
/*	This isn't supported in libmsocket yet
	else if (mso->type == LMSTYPE_LOCALLISTEN)
	{
		interface_local_accept(mso);
	}
	else if (mso->type == LMSTYPE_LOCALCLIENT)
	{
		interface_local_read(mso);
	}
*/
	else
	{
		/* This should be used for datagram sockets and such */
	}

	return;
}