BIO_PARSE_HOSTSERV(3ossl)
π BIO_PARSE_HOSTSERV π
okay bestie, so this is the BIO_PARSE_HOSTSERV(3ossl) page from the OpenSSL manual, and it's literally just two little utility routines that parse a standard host-and-service string. no cap, it's short and it's useful and we're gonna get through it together π«Ά
β¨ NAME β¨
BIO_hostserv_priorities, BIO_parse_hostserv β utility routines to parse a standard host and service string. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
here's the vibe, verbatim:
#include <openssl/bio.h>
enum BIO_hostserv_priorities {
BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
};
int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
enum BIO_hostserv_priorities hostserv_prio);
so we got an enum with two moods β BIO_PARSE_PRIO_HOST and BIO_PARSE_PRIO_SERV β and one function that takes four things. slay.
π¦ DESCRIPTION π¦
BIO_parse_hostserv() takes whatever you handed it in hostserv, parses it, builds you some fresh strings holding the hostname and the service name, and gives those back to you through host and service.
β οΈ heads up bestie: those strings need to be freed after they are used. not optional. free your memory, it's self care π
and what's hostserv_prio for? it helps determine whether hostserv shall be interpreted primarily as a hostname or as a service name in the ambiguous cases. it's the tiebreaker, the main character deciding who wins π
π the syntax it recognises
BIO_parse_hostserv() recognises exactly this:
host + ':' + service
host + ':' + '*'
host + ':'
':' + service
'*' + ':' + service
host
service
the host part can be a name or an IP address. and if it's a IPv6 address, it MUST be enclosed in brackets, such as '[::1]'. like, MUST must. brackets or nothing, babe π§
the service part can be a service name or its port number. a service name gets mapped to a port number using the system function getservbyname(). the system does the translating, we just vibe β¨
π what you actually get back
the returned values will depend on the given hostserv string and hostserv_prio, as follows:
host + ':' + service => *host = "host", *service = "service"
host + ':' + '*' => *host = "host", *service = NULL
host + ':' => *host = "host", *service = NULL
':' + service => *host = NULL, *service = "service"
'*' + ':' + service => *host = NULL, *service = "service"
so '*' means "no service for you", and a lone ':' before the service means "no host, just service". the NULLs are doing a lot of heavy lifting here, ngl π
in case no ':' is present in the string, the result depends on hostserv_prio, as follows:
when hostserv_prio == BIO_PARSE_PRIO_HOST
host => *host = "host", *service untouched
when hostserv_prio == BIO_PARSE_PRIO_SERV
service => *host untouched, *service = "service"
see? ambiguous input, the prio decides. it's giving "you pick, I trust you" ππ
π₯ RETURN VALUES π₯
BIO_parse_hostserv() returns 1 on success or 0 on error. that's the whole story. one or zero. iconic simplicity, periodt β
π SEE ALSO π
BIO_ADDRINFO(3) β go read that one next, bestie, it's the sequel π¦
π COPYRIGHT π
Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, no crumbs left πΈ this was the 3.5.9 version of the OpenSSL manual, dated 2026-09-29, and it's called BIO_PARSE_HOSTSERV(3ossl). mwah, take care of your strings and free them when you're done πππ«Ά
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms