Support UDP packets larger than 4 kB.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 21 Apr 2013 22:52:44 +0000 (00:52 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 21 Apr 2013 22:52:44 +0000 (00:52 +0200)
udpinput.cpp
udpinput.h

index 7caf8e1..3e4b9b7 100644 (file)
@@ -94,10 +94,9 @@ void UDPInput::do_work()
                        continue;
                }
 
-               char buf[4096];
                int ret;
                do {
-                       ret = recv(sock, buf, sizeof(buf), 0);
+                       ret = recv(sock, packet_buf, sizeof(packet_buf), 0);
                } while (ret == -1 && errno == EINTR);
 
                if (ret <= 0) {
@@ -107,7 +106,7 @@ void UDPInput::do_work()
                }
                
                for (size_t i = 0; i < stream_indices.size(); ++i) {
-                       servers->add_data(stream_indices[i], buf, ret);
+                       servers->add_data(stream_indices[i], packet_buf, ret);
                }
        }
 }
index e41266e..0ee5dc9 100644 (file)
@@ -39,6 +39,9 @@ private:
 
        // The socket we are receiving on (or -1).
        int sock;
+
+       // Temporary buffer, sized for the maximum size of an UDP packet.
+       char packet_buf[65536];
 };
 
 #endif  // !defined(_UDPINPUT_H)