]> git.sesse.net Git - cubemap/commitdiff
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 7caf8e196bd46db7ae6b7355815e567c96d52102..3e4b9b79c0cd872bcd140401b0f9a7a16238b21f 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 e41266e0dc3340a151d1a1a44a45748dcc628f1a..0ee5dc9b986f0cfa63026aac5c75c163dc3f87ab 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)