从套接字获取地址族.的Linux [英] Get address family from socket. Linux

查看:72
本文介绍了从套接字获取地址族.的Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Linux Socket API编写一个C ++包装器.在socket()中,请求地址族(AF).我不想再次要求在connect()签名中使用AF,因为它已在套接字的构造函数中给出.那么如何从现有的插槽中获取AF?

I want to write a C++ wrapper for the Linux Socket API. In the socket() ctor the adress family (AF) is requested. I dont want to require the AF in the connect() signature again, becuase it has been already given in the constructor of socket. So how do I get the AF from an existing socket?

推荐答案

该死.搜索了大约半个小时.现在,在发布此问题后,我很快就找到了答案.

Damn. Searched about half an hour. Now after posting this question I found immiediately the answer.

getsockopt([...]) 和选项SO_DOMAIN(请参见套接字选项)

getsockopt([...]) with option SO_DOMAIN (see socket options)

这篇关于从套接字获取地址族.的Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆