我试图了解以下(下面的代码)在做什么,并且正在努力理解 sockunions 的概念。谁能帮我吗?这与线程和线程文件描述符有什么关系?
提前感谢您的帮助,并愿意接受您推荐的任何资源!
莎拉
static int
bgp_accept (struct thread *thread)
{
int bgp_sock;
int accept_sock;
union sockunion su;
struct bgp_listener *listener = THREAD_ARG(thread);
struct peer *peer;
struct peer *peer1;
char buf[SU_ADDRSTRLEN];
/* Register accept thread. */
accept_sock = THREAD_FD (thread);
if (accept_sock < 0)
{
zlog_err ("accept_sock is nevative value %d", accept_sock);
return -1;
}
listener->thread = thread_add_read (master, bgp_accept, listener, accept_sock);
/* Accept client connection. */
bgp_sock = sockunion_accept (accept_sock, &su);
if (bgp_sock < 0)
{
...