MCPcopy Create free account
hub / github.com/3rdparty/libprocess / connect

Method connect

src/windows/poll_socket.cpp:138–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138Future<Nothing> PollSocketImpl::connect(
139 const Address& address)
140{
141 // Need to hold a copy of `this` so that the underlying socket
142 // doesn't end up getting reused before we return.
143 auto self = shared(this);
144
145 return windows::connect(self->get(), address)
146 .then([self]() -> Future<Nothing> {
147 // After the async connect (`ConnectEx`) is called, the socket is in a
148 // "default" state, which means it doesn't have the previously set
149 // properties or options set. We need to set `SO_UPDATE_CONNECT_CONTEXT`
150 // so that it regains its properties. For more information, see
151 // https://msdn.microsoft.com/en-us/library/windows/desktop/ms737606(v=vs.85).aspx // NOLINT(whitespace/line_length)
152 int res = ::setsockopt(
153 self->get(), SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, nullptr, 0);
154
155 if (res != 0) {
156 WindowsError error;
157 return Failure("Failed to set connected socket: " + error.message);
158 }
159
160 return Nothing();
161 });
162}
163
164
165Future<size_t> PollSocketImpl::recv(char* data, size_t size)

Callers

nothing calls this directly

Calls 4

FailureClass · 0.85
connectFunction · 0.70
thenMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected