@@ -178,9 +178,7 @@ void TCPWrap::New(const FunctionCallbackInfo<Value>& args) {
178178
179179TCPWrap::TCPWrap (Environment* env, Local<Object> object, ProviderType provider)
180180 : ConnectionWrap(env, object, provider) {
181- int r = uv_tcp_init (env->event_loop (), &handle_);
182- CHECK_EQ (r, 0 ); // How do we proxy this error up to javascript?
183- // Suggestion: uv_tcp_init() returns void.
181+ this ->InitializeHandle ();
184182}
185183
186184void TCPWrap::Reinitialize (const FunctionCallbackInfo<Value>& args) {
@@ -189,9 +187,7 @@ void TCPWrap::Reinitialize(const FunctionCallbackInfo<Value>& args) {
189187 ASSIGN_OR_RETURN_UNWRAP (
190188 &wrap, args.Holder (), args.GetReturnValue ().Set (UV_EBADF));
191189
192- Environment* env = wrap->env ();
193- int r = uv_tcp_init (env->event_loop (), &wrap->handle_ );
194- CHECK_EQ (r, 0 );
190+ wrap->InitializeHandle ();
195191}
196192
197193void TCPWrap::SetNoDelay (const FunctionCallbackInfo<Value>& args) {
@@ -394,6 +390,13 @@ int TCPWrap::Reset(Local<Value> close_callback) {
394390 return err;
395391}
396392
393+ void TCPWrap::InitializeHandle () {
394+ int r = uv_tcp_init (this ->env ()->event_loop (), &handle_);
395+
396+ CHECK_EQ (r, 0 ); // How do we proxy this error up to javascript?
397+ // Suggestion: uv_tcp_init() returns void.
398+ }
399+
397400// also used by udp_wrap.cc
398401MaybeLocal<Object> AddressToJS (Environment* env,
399402 const sockaddr* addr,
0 commit comments