Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: net/tools/quic/quic_socket_utils.cc

Issue 1752823002: n/a (QUIC toy client/server changes) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115400573
Patch Set: Revert to Patch Set 1 Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_socket_utils.cc
diff --git a/net/tools/quic/quic_socket_utils.cc b/net/tools/quic/quic_socket_utils.cc
index 36c5fb4366c684d08c7b5cbad24ed0130aec6b7e..42141dfa17b436892d7efe1d444bb59a181e3417 100644
--- a/net/tools/quic/quic_socket_utils.cc
+++ b/net/tools/quic/quic_socket_utils.cc
@@ -223,4 +223,39 @@ WriteResult QuicSocketUtils::WritePacket(int fd,
errno);
}
+// static
+int QuicSocketUtils::CreateUDPSocket(const IPEndPoint& address,
+ bool* overflow_supported) {
+ int address_family = address.GetSockAddrFamily();
+ int fd = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
+ if (fd < 0) {
+ LOG(ERROR) << "socket() failed: " << strerror(errno);
+ return -1;
+ }
+
+ int get_overflow = 1;
+ int rc = setsockopt(fd, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
+ sizeof(get_overflow));
+ if (rc < 0) {
+ DLOG(WARNING) << "Socket overflow detection not supported";
+ } else {
+ *overflow_supported = true;
+ }
+
+ if (!QuicSocketUtils::SetReceiveBufferSize(fd, kDefaultSocketReceiveBuffer)) {
+ return -1;
+ }
+
+ if (!QuicSocketUtils::SetSendBufferSize(fd, kDefaultSocketReceiveBuffer)) {
+ return -1;
+ }
+
+ rc = QuicSocketUtils::SetGetAddressInfo(fd, address_family);
+ if (rc < 0) {
+ LOG(ERROR) << "IP detection not supported" << strerror(errno);
+ return -1;
+ }
+ return fd;
+}
+
} // namespace net
« no previous file with comments | « net/tools/quic/quic_socket_utils.h ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698