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

Unified Diff: runtime/bin/socket_win.cc

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 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 | « runtime/bin/socket_patch.dart ('k') | runtime/bin/stdio_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_win.cc
diff --git a/runtime/bin/socket_win.cc b/runtime/bin/socket_win.cc
index 186c8f0b4b14772feb52a75ba455514d92db836a..a60f1e4294b8c458e64cc9bb822ffd1d7ee257fd 100644
--- a/runtime/bin/socket_win.cc
+++ b/runtime/bin/socket_win.cc
@@ -12,11 +12,15 @@
#include "bin/socket.h"
bool Socket::Initialize() {
+ static bool socket_initialized = false;
+ if (socket_initialized) return true;
int err;
WSADATA winsock_data;
- WORD version_requested = MAKEWORD(1, 0);
+ WORD version_requested = MAKEWORD(2, 2);
err = WSAStartup(version_requested, &winsock_data);
- if (err != 0) {
+ if (err == 0) {
+ socket_initialized = true;
+ } else {
Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError());
}
return err == 0;
@@ -190,6 +194,7 @@ intptr_t ServerSocket::Accept(intptr_t fd) {
const char* Socket::LookupIPv4Address(char* host, OSError** os_error) {
// Perform a name lookup for an IPv4 address.
+ Initialize();
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
@@ -265,7 +270,7 @@ intptr_t ServerSocket::CreateBindListen(const char* host,
return -1;
}
- status = listen(s, backlog);
+ status = listen(s, backlog > 0 ? backlog : SOMAXCONN);
if (status == SOCKET_ERROR) {
DWORD rc = WSAGetLastError();
closesocket(s);
@@ -280,7 +285,7 @@ intptr_t ServerSocket::CreateBindListen(const char* host,
void Socket::Close(intptr_t fd) {
ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
- client_socket->close();
+ client_socket->Close();
}
#endif // defined(TARGET_OS_WINDOWS)
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/bin/stdio_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698