// File: enbock[P]Warp10Server/ulib/src/Socket.cpp
// Function: u::Socket::connect()
bool u::Socket::connect()
{
	if(isConnected()) return false;

	lock();
	switch(_domain)
	{
		case AF_UNIX:
		{
			_con = ::connect(
				_descriptor
				, (const sockaddr*)_addr
				, _addrLen
			);
		} break;
		case AF_INET:
		case AF_INET6:
		default:
		{
			struct addrinfo hints, *servinfo, *p;
			memset(&hints, 0, sizeof hints);
			hints.ai_family = _domain;
			hints.ai_socktype = _type;

			if(::getaddrinfo(_hostname.c_str(), int2string((int)_port).c_str(), &hints, &servinfo) != 0)
			{
				error(className()+"::connect: Can't resolv hostname "+_hostname+":"
					+int2string(_port));
				return false;
			}

			for(p = servinfo; p != NULL; p = p->ai_next)
			{
				((struct sockaddr_in *)_addr)->sin_addr = ((struct sockaddr_in*)p->ai_addr)->sin_addr;
				_con = ::connect(_descriptor, (const struct sockaddr*)_addr, _addrLen);
				if(isConnected())
				{
					break;
				}
			}

			freeaddrinfo(servinfo);
		} break;
	}
	unlock();
	return isConnected();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x41aaf0
testb $0x1, %al
jne 0x41acf5
jmp 0x41acfe
movb $0x0, -0x1(%rbp)
jmp 0x41b218
movq -0x200(%rbp), %rdi
callq 0x417410
movq -0x200(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x204(%rbp)
subl $0x1, %eax
je 0x41ad3b
jmp 0x41ad21
movl -0x204(%rbp), %eax
subl $0x2, %eax
je 0x41ad62
jmp 0x41ad2e
movl -0x204(%rbp), %eax
subl $0xa, %eax
je 0x41ad62
jmp 0x41ad64
movq -0x200(%rbp), %rax
movl 0x34(%rax), %edi
movq 0x48(%rax), %rsi
movl 0x50(%rax), %edx
callq 0x56e180
movl %eax, %ecx
movq -0x200(%rbp), %rax
movl %ecx, 0x54(%rax)
jmp 0x41b1fb
jmp 0x41ad64
movq -0x200(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0x20(%rbp)
movaps %xmm0, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movl 0x38(%rdi), %eax
movl %eax, -0x3c(%rbp)
movl 0x40(%rdi), %eax
movl %eax, -0x38(%rbp)
addq $0x90, %rdi
callq 0x4af6a0
movq %rax, %rcx
movq -0x200(%rbp), %rax
movq %rcx, -0x210(%rbp)
movl 0xb0(%rax), %esi
leaq -0xa8(%rbp), %rdi
callq 0x4178a0
leaq -0x70(%rbp), %rdi
callq 0x4af6a0
movq -0x210(%rbp), %rdi
movq %rax, %rsi
leaq -0x40(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x5686c0
movl %eax, -0x208(%rbp)
jmp 0x41addd
leaq -0xa8(%rbp), %rdi
callq 0x405650
movl -0x208(%rbp), %eax
cmpl $0x0, %eax
je 0x41b194
movq $0x668b40, %rdi         # imm = 0x668B40
leaq 0x1c041a(%rip), %rsi    # 0x5db220
callq 0x49dd60
movq %rax, -0x218(%rbp)
movb $0x0, -0x191(%rbp)
movb $0x0, -0x192(%rbp)
movb $0x0, -0x193(%rbp)
movb $0x0, -0x194(%rbp)
movb $0x0, -0x1f1(%rbp)
movb $0x0, -0x1f3(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x41ae47
jmp 0x41af15
movq -0x200(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x190(%rbp), %rdi
callq *%rax
movb $0x1, -0x191(%rbp)
leaq -0x158(%rbp), %rsi
leaq 0x1c15ab(%rip), %rdx    # 0x5dc41e
leaq -0x138(%rbp), %rdi
callq 0x405d00
jmp 0x41ae81
movq -0x200(%rbp), %rdx
movb $0x1, -0x192(%rbp)
addq $0x90, %rdx
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x409520
jmp 0x41aeab
movb $0x1, -0x193(%rbp)
leaq 0x1c92f4(%rip), %rdx    # 0x5e41ad
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x405d00
jmp 0x41aece
movq -0x200(%rbp), %rax
movb $0x1, -0x194(%rbp)
movl 0xb0(%rax), %esi
leaq -0x1f0(%rbp), %rdi
callq 0x4178a0
jmp 0x41aef0
movb $0x1, -0x1f1(%rbp)
leaq -0x1b8(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x409d40
jmp 0x41af13
jmp 0x41af4d
leaq -0x1f2(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x435b90
movq -0x220(%rbp), %rdx
movb $0x1, -0x1f3(%rbp)
leaq 0x1e5a65(%rip), %rsi    # 0x6009a2
leaq -0xd8(%rbp), %rdi
callq 0x407e60
jmp 0x41af4b
jmp 0x41af4d
movq -0x218(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x228(%rbp)
jmp 0x41af69
movq -0x228(%rbp), %rdi
leaq 0x1c0159(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x230(%rbp)
jmp 0x41af85
movq -0x230(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x41af9a
leaq -0xd8(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x1f3(%rbp)
jne 0x41afb1
jmp 0x41afbd
leaq -0x1f2(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x1f1(%rbp)
jne 0x41afc8
jmp 0x41afd4
leaq -0x1f0(%rbp), %rdi
callq 0x405650
testb $0x1, -0x194(%rbp)
jne 0x41afdf
jmp 0x41afeb
leaq -0xf8(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x193(%rbp)
jne 0x41aff6
jmp 0x41b002
leaq -0x118(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x192(%rbp)
jne 0x41b00d
jmp 0x41b019
leaq -0x138(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x191(%rbp)
jne 0x41b024
jmp 0x41b030
leaq -0x190(%rbp), %rdi
callq 0x405650
movb $0x0, -0x1(%rbp)
jmp 0x41b218
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x405650
jmp 0x41b226
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b178
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b15f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b146
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b12d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x41b0fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x1f3(%rbp)
jne 0x41b106
jmp 0x41b112
leaq -0x1f2(%rbp), %rdi
callq 0x435bb0
jmp 0x41b114
testb $0x1, -0x1f1(%rbp)
jne 0x41b11f
jmp 0x41b12b
leaq -0x1f0(%rbp), %rdi
callq 0x405650
jmp 0x41b12d
testb $0x1, -0x194(%rbp)
jne 0x41b138
jmp 0x41b144
leaq -0xf8(%rbp), %rdi
callq 0x4adc60
jmp 0x41b146
testb $0x1, -0x193(%rbp)
jne 0x41b151
jmp 0x41b15d
leaq -0x118(%rbp), %rdi
callq 0x4adc60
jmp 0x41b15f
testb $0x1, -0x192(%rbp)
jne 0x41b16a
jmp 0x41b176
leaq -0x138(%rbp), %rdi
callq 0x4adc60
jmp 0x41b178
testb $0x1, -0x191(%rbp)
jne 0x41b183
jmp 0x41b18f
leaq -0x190(%rbp), %rdi
callq 0x405650
jmp 0x41b226
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x41b1f2
movq -0x200(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x18(%rcx), %rdx
movq 0x48(%rax), %rcx
movl 0x4(%rdx), %edx
movl %edx, 0x4(%rcx)
movl 0x34(%rax), %edi
movq 0x48(%rax), %rsi
movl 0x50(%rax), %edx
callq 0x56e180
movq -0x200(%rbp), %rdi
movl %eax, 0x54(%rdi)
callq 0x41aaf0
testb $0x1, %al
jne 0x41b1e0
jmp 0x41b1e2
jmp 0x41b1f2
jmp 0x41b1e4
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x41b19c
movq -0x48(%rbp), %rdi
callq 0x56ac40
movq -0x200(%rbp), %rdi
callq 0x417380
movq -0x200(%rbp), %rdi
callq 0x41aaf0
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x4deb40
nopw %cs:(%rax,%rax)