diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-06-16 00:59:46 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-06-26 20:43:44 +0200 |
| commit | 4e95ef0268137cf17c43f72863606803b0277bdf (patch) | |
| tree | cf4024616f97df84d8f305d8ec4baaba8695d854 /src/netops.c | |
| parent | 1b4f814025ca0c48477fb074929cd15f41f4f68f (diff) | |
| download | libgit2-4e95ef0268137cf17c43f72863606803b0277bdf.tar.gz | |
Implement and use gitno_send
Diffstat (limited to 'src/netops.c')
| -rw-r--r-- | src/netops.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/netops.c b/src/netops.c index 04f758fa4..532d0d3d0 100644 --- a/src/netops.c +++ b/src/netops.c @@ -23,9 +23,15 @@ * Boston, MA 02110-1301, USA. */ -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> +#ifndef _MSC_VER +# include <sys/types.h> +# include <sys/socket.h> +# include <netdb.h> +#else +# include <winsock2.h> +# include <Ws2tcpip.h> +# pragma comment(lib, "Ws2_32.lib") +#endif #include "git2/errors.h" @@ -74,3 +80,18 @@ cleanup: freeaddrinfo(info); return error; } + +int gitno_send(int s, const char *msg, int len, int flags) +{ + int ret, off = 0; + + while (off < len) { + ret = send(s, msg + off, len - off, flags); + if (ret < 0) + return GIT_EOSERR; + + off += ret; + } + + return off; +} |
