]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/rscript/send_functor.h
Fix trailing whitespaces.
[stg.git] / projects / stargazer / plugins / other / rscript / send_functor.h
index 479cdc3b84275b6fc67ae32a0f32b393b7ac46c2..dc8ad63a2017f5e41c0c2112b24767672592f79c 100644 (file)
 #ifndef __SEND_FUNCTOR_H__
 #define __SEND_FUNCTOR_H__
 
 #ifndef __SEND_FUNCTOR_H__
 #define __SEND_FUNCTOR_H__
 
-#include <sys/types.h>
-#include <sys/socket.h>
+#include "stg/os_int.h"
 
 #include <functional>
 
 
 #include <functional>
 
-#include "os_int.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
 
 
-class PacketSender : public std::unary_function<uint32_t, void> {
+class PacketSender : public std::unary_function<uint32_t, ssize_t> {
     public:
     public:
-        PacketSender(int s, char * b, int l, uint16_t p)
+        PacketSender(int s, char * b, size_t l, uint16_t p)
             : sock(s),
               buffer(b),
               length(l),
             : sock(s),
               buffer(b),
               length(l),
-              port(p) {};
-        void operator() (uint32_t ip)
+              port(p) {}
+        ssize_t operator() (uint32_t ip)
         {
         {
-        int res;
         struct sockaddr_in sendAddr;
 
         sendAddr.sin_family = AF_INET;
         sendAddr.sin_port = port;
         sendAddr.sin_addr.s_addr = ip;
 
         struct sockaddr_in sendAddr;
 
         sendAddr.sin_family = AF_INET;
         sendAddr.sin_port = port;
         sendAddr.sin_addr.s_addr = ip;
 
-        res = sendto(sock, buffer, length, 0, (struct sockaddr*)&sendAddr, sizeof(sendAddr));
+        return sendto(sock, buffer, length, 0, (struct sockaddr*)&sendAddr, sizeof(sendAddr));
         }
     private:
         int sock;
         char * buffer;
         }
     private:
         int sock;
         char * buffer;
-        int length;
+        size_t length;
         uint16_t port;
 };
 
         uint16_t port;
 };