// File: Unreality3D[P]Unreality3D/indie-studio/source/Network/sockets/Client.cpp
// Function: Socket::Client::stateChecker()
void Client::stateChecker()
  {
    int fd;
    int nb_fd;
    fd_set read_set, write_set;
    timeval timeout;

    // event loop
    while (_isRunning)
      {
	SLEEPMS(0);
	memcpy(&read_set, &_fd_set, sizeof(_fd_set));
	memcpy(&write_set, &_fd_set, sizeof(_fd_set));

	timeout = _timeout;
	// wait for an event
	nb_fd = select(_fd + 1, &read_set, &write_set, NULL, &timeout);
	if (nb_fd < 0 && errno != EINTR)
	  throw SocketIOError(std::string(strerror(getError())));

	if (FD_ISSET(_fd, &read_set))
	  {
	    // read event
	    if (bytesAvailables() == 0)
	      {
		break;
	      }
	    else if (_OnReadPossible)
	      _OnReadPossible(*this, bytesAvailables());
	  }

	// write event
	if (FD_ISSET(_fd, &write_set))
	  {
	    if (_OnWritePossible)
	      _OnWritePossible(*this);
	  }
      }
    disconnect();
  }

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x190(%rsp)
movq 0x190(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
callq 0x29500
testb $0x1, %al
jne 0x3fa76
jmp 0x3fd1f
xorl %edi, %edi
callq 0x2ac80
movq 0x40(%rsp), %rsi
addq $0xe8, %rsi
leaq 0x108(%rsp), %rdi
movl $0x80, %edx
callq 0x29a50
movq 0x40(%rsp), %rsi
addq $0xe8, %rsi
leaq 0x88(%rsp), %rdi
movl $0x80, %edx
callq 0x29a50
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rcx
movq %rcx, 0x78(%rsp)
movq 0x40(%rax), %rcx
movq %rcx, 0x80(%rsp)
movl 0x2c(%rax), %edi
addl $0x1, %edi
leaq 0x108(%rsp), %rsi
leaq 0x88(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
leaq 0x78(%rsp), %r8
callq 0x29ed0
movl %eax, 0x188(%rsp)
cmpl $0x0, 0x188(%rsp)
jge 0x3fbf9
callq 0x280d0
cmpl $0x4, (%rax)
je 0x3fbf9
movb $0x1, 0x4a(%rsp)
movl $0x48, %edi
callq 0x28e70
movq %rax, 0x30(%rsp)
callq 0x3f9d0
movl %eax, 0x3c(%rsp)
jmp 0x3fb39
movl 0x3c(%rsp), %edi
callq 0x28970
movq %rax, 0x20(%rsp)
leaq 0x4b(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x2b730
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x58(%rsp), %rdi
callq 0x2aa80
jmp 0x3fb6c
movq 0x30(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2afd0
jmp 0x3fb7d
movq 0x30(%rsp), %rdi
movb $0x0, 0x4a(%rsp)
movq 0x133fa(%rip), %rsi     # 0x52f88
movq 0x1339b(%rip), %rdx     # 0x52f30
callq 0x2b540
jmp 0x3fd3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x3fbe1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x3fbd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x29360
leaq 0x4b(%rsp), %rdi
callq 0x2a210
testb $0x1, 0x4a(%rsp)
jne 0x3fbea
jmp 0x3fbf4
movq 0x30(%rsp), %rdi
callq 0x29690
jmp 0x3fd31
movq 0x40(%rsp), %rax
movl 0x2c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq 0x40(%rsp), %rax
movslq %ecx, %rcx
movq 0x108(%rsp,%rcx,8), %rcx
movq %rcx, 0x18(%rsp)
movl 0x2c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq 0x18(%rsp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x3fca0
movq 0x40(%rsp), %rdi
callq 0x28bb0
cmpq $0x0, %rax
jne 0x3fc5b
jmp 0x3fd1f
movq 0x40(%rsp), %rdi
addq $0x88, %rdi
callq 0x28900
testb $0x1, %al
jne 0x3fc72
jmp 0x3fc9c
movq 0x40(%rsp), %rdi
movq %rdi, %rax
addq $0x88, %rax
movq %rax, 0x10(%rsp)
callq 0x28bb0
movq 0x10(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %rax, %rdx
callq 0x2a790
jmp 0x3fc9e
jmp 0x3fca0
movq 0x40(%rsp), %rax
movl 0x2c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq 0x40(%rsp), %rax
movslq %ecx, %rcx
movq 0x88(%rsp,%rcx,8), %rcx
movq %rcx, 0x8(%rsp)
movl 0x2c(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq 0x8(%rsp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x3fd1a
movq 0x40(%rsp), %rdi
addq $0xa8, %rdi
callq 0x2a180
testb $0x1, %al
jne 0x3fd04
jmp 0x3fd18
movq 0x40(%rsp), %rsi
movq %rsi, %rdi
addq $0xa8, %rdi
callq 0x2bae0
jmp 0x3fd1a
jmp 0x3fa5c
movq 0x40(%rsp), %rdi
callq 0x2b1c0
addq $0x198, %rsp            # imm = 0x198
retq
movq 0x50(%rsp), %rdi
callq 0x2b6f0
nopl (%rax,%rax)