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

Side by Side Diff: src/platform-posix.cc

Issue 5990001: Allow rapid socket reuse on POSIX platforms. (Closed)
Patch Set: Created 10 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // ---------------------------------------------------------------------------- 198 // ----------------------------------------------------------------------------
199 // POSIX socket support. 199 // POSIX socket support.
200 // 200 //
201 201
202 class POSIXSocket : public Socket { 202 class POSIXSocket : public Socket {
203 public: 203 public:
204 explicit POSIXSocket() { 204 explicit POSIXSocket() {
205 // Create the socket. 205 // Create the socket.
206 socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 206 socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
207 if (IsValid()) {
208 // Allow rapid reuse.
209 static const int kOn = 1;
210 int ret = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
211 &kOn, sizeof(kOn));
212 ASSERT(ret == 0);
213 USE(ret);
214 }
207 } 215 }
208 explicit POSIXSocket(int socket): socket_(socket) { } 216 explicit POSIXSocket(int socket): socket_(socket) { }
209 virtual ~POSIXSocket() { Shutdown(); } 217 virtual ~POSIXSocket() { Shutdown(); }
210 218
211 // Server initialization. 219 // Server initialization.
212 bool Bind(const int port); 220 bool Bind(const int port);
213 bool Listen(int backlog) const; 221 bool Listen(int backlog) const;
214 Socket* Accept() const; 222 Socket* Accept() const;
215 223
216 // Client initialization. 224 // Client initialization.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return ntohl(value); 366 return ntohl(value);
359 } 367 }
360 368
361 369
362 Socket* OS::CreateSocket() { 370 Socket* OS::CreateSocket() {
363 return new POSIXSocket(); 371 return new POSIXSocket();
364 } 372 }
365 373
366 374
367 } } // namespace v8::internal 375 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698