#include "gnunet_resolver_service.h"
+/**
+ * Timeout we use on TCP connect before trying another
+ * result from the DNS resolver. Actual value used
+ * is this value divided by the number of address families.
+ * Default is 5s.
+ */
+#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
+
#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
struct GNUNET_CONNECTION_Handle *connection;
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->sock = osSocket;
return connection;
return NULL;
}
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->addr = uaddr;
connection->addrlen = addrlen;
return;
}
GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap);
- delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT;
+ delay = CONNECT_RETRY_TIMEOUT;
if (NULL != connection->nth.notify_ready)
delay = GNUNET_TIME_relative_min (delay,
GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
GNUNET_assert (0 < strlen (hostname)); /* sanity check */
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = port;
connection->hostname = GNUNET_strdup (hostname);
connection->dns_active =
GNUNET_RESOLVER_ip_get (connection->hostname,
AF_UNSPEC,
- GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
+ CONNECT_RETRY_TIMEOUT,
&try_connect_using_address,
connection);
return connection;
#endif
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = 0;
connection->hostname = NULL;
* @param timeout maximum amount of time to wait
* @param receiver function to call with received data
* @param receiver_cls closure for @a receiver
+ * @return #GNUNET_SYSERR if @a connection died (receiver was
+ * called with error)
*/
-void
+int
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
size_t max,
struct GNUNET_TIME_Relative timeout,
connection->sock,
&receive_ready,
connection);
- return;
+ return GNUNET_OK;
}
if ((NULL == connection->dns_active) &&
(NULL == connection->ap_head) &&
NULL, 0,
NULL, 0,
ETIMEDOUT);
- return;
+ return GNUNET_SYSERR;
}
+ return GNUNET_OK;
}
return NULL;
}
GNUNET_assert (NULL != notify);
- GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off);