]> Nishi Git Mirror - libw3.git/commitdiff
WSASend
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Tue, 6 Feb 2024 01:34:56 +0000 (01:34 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Tue, 6 Feb 2024 01:34:56 +0000 (01:34 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@169 d27a3e52-49c5-7645-884c-6793ebffc270

Library/Util.c
W3Version.h.p

index 9c461a40d336113d8d251d96eb7c7db8e67da929..9484c57c07ec365e3dba67b86b9c977ef1042003 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifdef __MINGW32__
 #include <windows.h>
-#include <winsock.h>
+#include <winsock2.h>
 #else
 #include <netdb.h>
 #include <netinet/in.h>
@@ -59,11 +59,29 @@ unsigned long __W3_Auto_Write(struct W3* w3, char* data, unsigned long length) {
        if(w3->ssl != NULL) {
                return SSL_write(w3->ssl, data, length);
        } else {
-               return send(w3->sock, data, length, 0);
+#ifdef __MINGW32__
+               int sent_bytes;
+               WSABUF buf;
+               buf.len = length;
+               buf.buf = data;
+               int r = WSASend(w3->sock, &buf, 1, &sent_bytes, 0, NULL, NULL);
+               return r == SOCKET_ERROR ? -1 : sent_bytes;
+#else
+               return send(w3->sock, data, length, 0)+
+#endif
        }
+#else
+#ifdef __MINGW32__
+       int sent_bytes;
+       WSABUF buf;
+       buf.len = length;
+       buf.buf = data;
+       int r = WSASend(w3->sock, &buf, 1, &sent_bytes, 0, NULL, NULL);
+       return r == SOCKET_ERROR ? -1 : sent_bytes;
 #else
        return send(w3->sock, data, length, 0);
 #endif
+#endif
 }
 
 unsigned long __W3_Auto_Read(struct W3* w3, char* data, unsigned long length) {
index f852b65735a6599c8e35280e574e6df94810c498..df48299ff16c94900f9f28b4cf36c840c9af8f37 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "2.2N" \
+#define LIBW3_VERSION "2.2O" \
 SUFFIX
 
 #ifdef __cplusplus