network protocols

Christian Heimes lists at cheimes.de
Wed Jun 13 14:33:39 EDT 2012


Am 13.06.2012 16:56, schrieb Christian Heimes:
> Am 13.06.2012 13:41, schrieb Tarek Ziadé:
>> Hey
>>
>> I was surprised not to find any way to list all protocol names listed in
>> /etc/protocols in Python
>>
>> We have
>>
>> socket.getprotobyname(NAME)
>>
>> But there's no way to get the list of names
>>
>> Any ideas if this is available in the stdlib somehwere ?
> 
> No, I can't find any reference to the relevant NSS APIs in the Python
> code. You can easily roll your own with ctypes:

PS: You can also parse the output of "getent protocols". As for all name
services you shouldn't parse the file as other sources (ldap, dns, nis,
databases) can provide additional information. See man nsswitch.conf

Christian




More information about the Python-list mailing list