diff --git a/net/sock.c b/net/sock.c index f31491b..d5a8f51 100644 --- a/net/sock.c +++ b/net/sock.c @@ -314,6 +314,15 @@ int sock_write(sock_t sock, const char *fmt, ...) return sock_write_bytes(sock, buff, strlen(buff)); } +int sock_write_fmt(sock_t sock, char *fmt, va_list ap) +{ + char buff[1024]; + + vsnprintf(buff, 1024, fmt, ap); + + return sock_write_bytes(sock, buff, strlen(buff)); +} + int sock_read_bytes(sock_t sock, char *buff, const int len) { diff --git a/net/sock.h b/net/sock.h index 6944bd0..c4d78e7 100644 --- a/net/sock.h +++ b/net/sock.h @@ -22,6 +22,7 @@ #ifndef __SOCK_H #define __SOCK_H +#include #ifdef _WIN32 #include @@ -87,6 +88,7 @@ int sock_connected (int sock, unsigned timeout); /* Socket write functions */ int sock_write_bytes(sock_t sock, const void *buff, const size_t len); int sock_write(sock_t sock, const char *fmt, ...); +int sock_write_fmt(sock_t sock, char *fmt, va_list ap); int sock_write_string(sock_t sock, const char *buff); ssize_t sock_writev (int sock, const struct iovec *iov, const size_t count);