diff --git a/src/transport/tcp.c b/src/transport/tcp.c index 44e8015..26e4064 100644 --- a/src/transport/tcp.c +++ b/src/transport/tcp.c @@ -27,12 +27,21 @@ #include #include #include -#include -#include -#include +#ifdef __WIN32__ +# include +#else +# include +# include +# include +#endif #include #include "App/apptransport.h" +/* portability */ +#ifdef __WIN32__ +# define close(fd) closesocket(fd) +#endif + /* TCP */ /* private */ @@ -539,8 +548,8 @@ static int _tcp_socket_callback_read(int fd, TCPSocket * tcpsocket) if((p = realloc(tcpsocket->bufin, tcpsocket->bufin_cnt + inc)) == NULL) return -1; tcpsocket->bufin = p; - if((ssize = read(tcpsocket->fd, &tcpsocket->bufin[tcpsocket->bufin_cnt], - inc)) < 0) + if((ssize = recv(tcpsocket->fd, &tcpsocket->bufin[tcpsocket->bufin_cnt], + inc, 0)) < 0) { error_set_code(1, "%s", strerror(errno)); close(tcpsocket->fd); @@ -579,8 +588,8 @@ static int _tcp_socket_callback_write(int fd, TCPSocket * tcpsocket) /* check parameters */ if(tcpsocket->fd != fd) return -1; - if((ssize = write(tcpsocket->fd, tcpsocket->bufout, - tcpsocket->bufout_cnt)) < 0) + if((ssize = send(tcpsocket->fd, tcpsocket->bufout, + tcpsocket->bufout_cnt, 0)) < 0) { /* XXX report error (and reconnect) */ error_set_code(1, "%s", strerror(errno)); diff --git a/src/transport/udp.c b/src/transport/udp.c index be96394..056e423 100644 --- a/src/transport/udp.c +++ b/src/transport/udp.c @@ -25,12 +25,21 @@ #include #include #include -#include -#include -#include +#ifdef __WIN32__ +# include +#else +# include +# include +# include +#endif #include #include "App/apptransport.h" +/* portability */ +#ifdef __WIN32__ +# define close(fd) closesocket(fd) +#endif + /* UDP */ /* private */