retransmit(c);
}
+ if(c->poll && c->sndbufsize < c->maxsndbufsize / 2)
+ c->poll(c, c->maxsndbufsize - c->sndbufsize);
+
if(timerisset(&c->conn_timeout) && timercmp(&c->conn_timeout, &next, <))
next = c->conn_timeout;
return c->maxsndbufsize;
}
+size_t utcp_get_sndbuf_free(struct utcp_connection *c) {
+ return c->maxsndbufsize - c->sndbufsize;
+}
+
void utcp_set_sndbuf(struct utcp_connection *c, size_t size) {
c->maxsndbufsize = size;
if(c->maxsndbufsize != size)
size_t utcp_get_outq(struct utcp_connection *c) {
return seqdiff(c->snd.nxt, c->snd.una);
}
+
+void utcp_set_recv_cb(struct utcp_connection *c, utcp_recv_t recv) {
+ c->recv = recv;
+}
+
+void utcp_set_poll_cb(struct utcp_connection *c, utcp_poll_t poll) {
+ c->poll = poll;
+}
typedef ssize_t (*utcp_send_t)(struct utcp *utcp, const void *data, size_t len);
typedef ssize_t (*utcp_recv_t)(struct utcp_connection *connection, const void *data, size_t len);
+typedef void (*utcp_poll_t)(struct utcp_connection *connection, size_t len);
+
extern struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_send_t send, void *priv);
extern void utcp_exit(struct utcp *utcp);
extern int utcp_abort(struct utcp_connection *connection);
extern int utcp_shutdown(struct utcp_connection *connection, int how);
extern int utcp_timeout(struct utcp *utcp);
+extern void utcp_set_recv_cb(struct utcp_connection *connection, utcp_recv_t recv);
+extern void utcp_set_poll_cb(struct utcp_connection *connection, utcp_poll_t poll);
// Global socket options
extern size_t utcp_get_sndbuf(struct utcp_connection *connection);
extern void utcp_set_sndbuf(struct utcp_connection *connection, size_t size);
+extern size_t utcp_get_sndbuf_free(struct utcp_connection *connection);
+
extern bool utcp_get_nodelay(struct utcp_connection *connection);
extern void utcp_set_nodelay(struct utcp_connection *connection, bool nodelay);