# NonBlocking Socket Connect Error Code - EINPROGRESS

**URL:** <https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 26, 2016, 1:56pm UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662 "2016-09-26T13:56:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_764aadfa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_764aadfa](https://forums.unrealengine.com/u/anonymous_user_764aadfa)\
**Post date:** [September 26, 2016, 1:56pm UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662/1 "2016-09-26T13:56:14Z")

</div>

When initializing socket with nonblocking mode and connect to, it usually returns error code -1, SE\_EINPROGRESS.

```
bool FSocketBSD::Connect(const FInternetAddr& Addr)
{
	int32 Return = connect(Socket, (sockaddr*)(FInternetAddrBSD&)Addr, sizeof(sockaddr_in));
	
	check(SocketSubsystem);
	ESocketErrors Error = SocketSubsystem->TranslateErrorCode(Return);

	// "would block" is not an error
	return ((Error == SE_NO_ERROR) || (Error == SE_EWOULDBLOCK));
}

```

But in nonblocking mode, when facing this error code, usually someone needs to check socket status with select/poll whatever for checking read/write status later.  
so in somewhat means it’s not the error situation for handling as error right returning from connect function.

is there any good idea for handling this error code?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [September 26, 2016, 3:01pm UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662/2 "2016-09-26T15:01:25Z")

</div>

Hey belliny.kim,

Can you please tell me what you mean by this?:

> so in somewhat means it’s not the error situation for handling as error right returning from connect function.

Thanks.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_764aadfa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_764aadfa](https://forums.unrealengine.com/u/anonymous_user_764aadfa)\
**Post date:** [September 27, 2016, 5:50am UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662/3 "2016-09-27T05:50:57Z")

</div>

Hello,

Thank you for reviewing my post.

i’ve wrote below code for connect to server,

```
	// Endpoint, initializing w/ destination info
	FIPv4Endpoint Endpoint;
	.......

	// allocate new socket, nonblocking mode
	Socket = FTcpSocketBuilder(TEXT("...")).AsReusable().AsNonBlocking();
	if (true == Socket->Connect(*Endpoint.ToInternetAddr()))
	{
		return true;
	}
	else
	{
		// EINPROGRESS is returned
		// do something for handling this situation
	}

```

and, below code(not exactly same, it’s abs. form) for monitoring socket status within every tick(or runnable thread)

```
	if (nullptr == Socket)
	{
		return;
	}
	
	ESocketConnectionState eNewSockState = Socket->GetConnectionState();
	if (ESocketConnectionState::SCS_Connected == eNewSockState)
	{
		// connected to server
	}
	else if (...)
	{
		// do something else
		...
	}

```

even i’ve got EINPROGRESS(Connect function returns false as it’s not SE\_NO\_ERROR nor SE\_EWOULDBLOCK), socket is still working in async and got connection if it’s reachable to server.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [September 28, 2016, 3:50pm UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662/4 "2016-09-28T15:50:58Z")

</div>

Hey belliny.kim,

This issue has already been logged and is being tracked. You can follow it here:

[https://issues.unrealengine.com/issue/UE-2248](https://issues.unrealengine.com/issue/UE-2248)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_764aadfa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_764aadfa](https://forums.unrealengine.com/u/anonymous_user_764aadfa)\
**Post date:** [September 29, 2016, 12:57am UTC](https://forums.unrealengine.com/t/nonblocking-socket-connect-error-code-einprogress/371662/5 "2016-09-29T00:57:41Z")

</div>

Thanks!  
it’s been so long time past since the UE-2248 posted. ☹  
I hope it’ll be soon progressed.
