当前位置: 技术问答>linux和unix
求指教:sendmsg函数具体实现过程
来源: 互联网 发布时间:2016-07-22
本文导语: linux中有send/sendto/sendmsg来发送消息,其中sendmsg可用于连接和非连接的套接字,想了解下sendmsg的具体实现过程,请大虾们指点下。 | 内核函数参考一下? static int sendmsg(struct IsdnCardState *cs, u...
linux中有send/sendto/sendmsg来发送消息,其中sendmsg可用于连接和非连接的套接字,想了解下sendmsg的具体实现过程,请大虾们指点下。
|
内核函数参考一下?
static int
sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
u_char *msg)
{
int i;
if (!waitforHIA(cs, 4000))
return(0);
#if DUMP_MBOXFRAME
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "sendmsg(%02x,%02x,%d)", his, creg, len);
#endif
cs->BC_Write_Reg(cs, 0, ISAR_CTRL_H, creg);
cs->BC_Write_Reg(cs, 0, ISAR_CTRL_L, len);
cs->BC_Write_Reg(cs, 0, ISAR_WADR, 0);
if (msg && len) {
cs->BC_Write_Reg(cs, 1, ISAR_MBOX, msg[0]);
for (i=1; iBC_Write_Reg(cs, 2, ISAR_MBOX, msg[i]);
#if DUMP_MBOXFRAME>1
if (cs->debug & L1_DEB_HSCX_FIFO) {
char tmp[256], *t;
i = len;
while (i>0) {
t = tmp;
t += sprintf(t, "sendmbox cnt %d", len);
QuickHex(t, &msg[len-i], (i>64) ? 64:i);
debugl1(cs, tmp);
i -= 64;
}
}
#endif
}
cs->BC_Write_Reg(cs, 1, ISAR_HIS, his);
waitforHIA(cs, 10000);
return(1);
}
|
您可以参考这个
sendmsg(经socket传送数据)
表头文件#include
int sendmsg(int s,const strcut msghdr *msg, unsigned int flags);
.......
http://www.phpfans.net/manu/Linux_C/%BD%D3%BF%DA%B4%A6%C0%ED%C6%AA/sendmsg.htm
sendmsg(经socket传送数据)
表头文件#include
int sendmsg(int s,const strcut msghdr *msg, unsigned int flags);
.......
http://www.phpfans.net/manu/Linux_C/%BD%D3%BF%DA%B4%A6%C0%ED%C6%AA/sendmsg.htm