-/*
- * Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
/** \file net.c Networking-related helper functions. */
* directly after makesock(). The 'pre_conn_opt' structure is for internal use
* only and should not be visible elsewhere.
*
- * \sa setsockopt(2), makesock()
+ * \sa setsockopt(2), \ref makesock().
*/
struct pre_conn_opt {
int sock_level; /**< Second argument to setsockopt() */
for (; ai; ai = ai->ai_next) {
int fd;
ret = socket(ai->ai_family, sock_type(l4type), l4type);
- if (ret < 0)
+ if (ret < 0) {
+ PARA_NOTICE_LOG("socket(): %s\n", strerror(errno));
continue;
+ }
fd = ret;
flowopt_setopts(fd, fo);
if (!passive) {
- if (connect(fd, ai->ai_addr, ai->ai_addrlen) == 0)
- return fd;
- close(fd);
- continue;
+ if (connect(fd, ai->ai_addr, ai->ai_addrlen) < 0) {
+ PARA_NOTICE_LOG("connect(): %s\n",
+ strerror(errno));
+ close(fd);
+ continue;
+ }
+ return fd;
}
/*
* Reuse the address on passive sockets to avoid failure on
*/
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
sizeof(on)) == -1) {
+ PARA_NOTICE_LOG("setsockopt(): %s\n", strerror(errno));
close(fd);
continue;
}
if (bind(fd, ai->ai_addr, ai->ai_addrlen) < 0) {
+ PARA_NOTICE_LOG("bind(): %s\n", strerror(errno));
close(fd);
continue;
}
*
* \param l4type The transport-layer type (\p IPPROTO_xxx).
* \param port The decimal port number to listen on.
- * \param fo Flowopts (if any) to set before starting to listen.
*
* \return Positive integer (socket descriptor) on success, negative value
* otherwise.
*
* \sa \ref makesock(), ip(7), ipv6(7), bind(2), listen(2).
*/
-int para_listen(unsigned l4type, uint16_t port, struct flowopts *fo)
+int para_listen_simple(unsigned l4type, uint16_t port)
{
- int ret, fd = makesock(l4type, 1, NULL, port, fo);
+ int ret, fd = makesock(l4type, 1, NULL, port, NULL);
if (fd > 0) {
ret = listen(fd, BACKLOG);
* \return A static character string identifying hostname and port of the
* chosen side in numeric host:port format.
*
- * \sa getsockname(2), getpeername(2), parse_url(), getnameinfo(3),
+ * \sa getsockname(2), getpeername(2), \ref parse_url(), getnameinfo(3),
* services(5), nsswitch.conf(5).
*/
char *remote_name(int fd)
*
* \return The return value of the underlying call to \a recv_bin_buffer().
*
- * \sa recv_bin_buffer()
+ * \sa \ref recv_bin_buffer()
*/
int recv_buffer(int fd, char *buf, size_t size)
{
* \return The file descriptor of the connected socket on success, negative on
* errors.
*
- * \sa create_local_socket(), unix(7), connect(2).
+ * \sa \ref create_local_socket(), unix(7), connect(2).
*/
int connect_local_socket(const char *name)
{
* \return On success, this call returns the number of bytes sent. On errors,
* \p -E_SENDMSG is returned.
*
- * \sa \ref recv_cred_buffer, sendmsg(2), socket(7), unix(7), okir's Black Hats
- * Manual.
+ * \sa \ref recv_cred_buffer, sendmsg(2), socket(7), unix(7).
*/
ssize_t send_cred_buffer(int sock, char *buf)
{