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

Unified Diff: runtime/bin/socket_win.cc

Issue 15966002: Add support for loading scripts from http (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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_macos.cc ('k') | no next file » | 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 60a6163b4e0bfbe159b202f13575814402fb1d2e..e53a28d832da28db66224d69fcc9442309472390 100644
--- a/runtime/bin/socket_win.cc
+++ b/runtime/bin/socket_win.cc
@@ -113,7 +113,8 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) {
return true;
}
-intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) {
+
+intptr_t Socket::Create(RawAddr addr) {
SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0);
if (s == INVALID_SOCKET) {
return -1;
@@ -131,6 +132,15 @@ intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) {
FATAL("Failed setting SO_LINGER on socket");
}
+ ClientSocket* client_socket = new ClientSocket(s);
+ return reinterpret_cast<intptr_t>(client_socket);
+}
+
+
+intptr_t Socket::Connect(intptr_t fd, RawAddr addr, const intptr_t port) {
+ ASSERT(reinterpret_cast<Handle*>(fd)->is_socket());
+ SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
+ SOCKET s = handle->socket();
SocketAddress::SetAddrPort(&addr, port);
status = connect(
s,
@@ -138,13 +148,21 @@ intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) {
SocketAddress::GetAddrLength(addr));
if (status == SOCKET_ERROR) {
DWORD rc = WSAGetLastError();
- closesocket(s);
+ handle->close();
SetLastError(rc);
return -1;
}
+ return fd;
+}
- ClientSocket* client_socket = new ClientSocket(s);
- return reinterpret_cast<intptr_t>(client_socket);
+
+intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) {
+ intptr_t fd = Socket::Create(addr);
+ if (fd < 0) {
+ return fd;
+ }
+
+ return Socket::Connect(fd, addr, port);
}
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698