




但是,unrealircd(包括其它ircd)的消息都是遵循IRC协议以\r\n来尾的,如果ircd不做任何改动的话,XMLSocket是不会收到ircd传递过来的信息,同时XMLSocket发出的命令IRC也不可能正确的进行解析与执行。
如果你想让unrealircd能与XMLSocket协同工作,请按以下步聚操作:
一,修改unrealircd源码,让其可以正确解析XMLSocket发出的命令:
找到源文件packet.c,如下代码片,约在118行左右,并根据提示进行修改:
/*
* Yuck. Stuck. To make sure we stay backward compatible,
* we must assume that either CR or LF terminates the message
* and not CR-LF. By allowing CR or LF (alone) into the body
* of messages, backward compatibility is lost and major
* problems will arise. - Avalon
*/
if (g < '\16' && (g == '\0' || g == '\n' || g == '\r')) //注意:红色粗体部分是所做的改动
{
if (ch1 == cptr->buffer)
continue; /* Skip extra LF/CR's */
*ch1 = '\0';


}

* Yuck. Stuck. To make sure we stay backward compatible,
* we must assume that either CR or LF terminates the message
* and not CR-LF. By allowing CR or LF (alone) into the body
* of messages, backward compatibility is lost and major
* problems will arise. - Avalon
*/

{
if (ch1 == cptr->buffer)
continue; /* Skip extra LF/CR's */
*ch1 = '\0';


}

二,修改unrealircd源码,让其消息可以被XMLSocket正确接收:
找到socket.c源文件,根据如下提示操作:
1,约92行左右,找到如下行:
retval = send(cptr->fd, str, len, 0);
2,修改为如下代码:{
str[len]='\0';
retval = send(cptr->fd, str, len, 0);
send(cptr->fd, "\0", 1, 0);
}
str[len]='\0';
retval = send(cptr->fd, str, len, 0);
send(cptr->fd, "\0", 1, 0);
}
然后对其重新编译,现在,你的ircd已经可以支持flash XMLSocket了。你可以写一个flash的测试端来进行测试了,请看我随后的文章里的介绍:用flash测试你的ircd。
提示:这样修改后,对于正常的IRC客户端软件连接又会带来一定的问题,以致于有些消息不能被正常解析,如mirc等,最好的办法是扩展IRC协议并修改ircd源码,让其能根据不同的客户端类型发送不同的消息格式,随后在我应用到时,我再写文章来详细如何改造。