void sock_cb(int fd, void *user_data)
{
int size;
char buf[MAX_BUF_SIZE];
struct lgsm_handle *handle=(struct lgsm_handle*)user_data;
size = read(fd, buf, MAX_BUF_SIZE);
if (size > 0) {
handle_packet_greedy(handle, buf, size, NULL);
return;
} else if (size == 0) { /* EOF */
return;
} else {
g_warning("cs_dispatch:%s %s",
"read error from libgsmd:",
g_strerror(errno));
return;
}
}
fltk::add_fd(fd, READ, sock_cb, handle);//一有数据发到该socket,就会执行sock_cb
阅读(2129) | 评论(0) | 转发(0) |