// File: enbock[P]Warp10Server/warp10server/src/Network/WebListener.cpp
// Function: Warp10::Network::WebListener::listenSocket(u::Object*)
void WebListener::listenSocket(Object* arg)
{
	lock();
	Socket* listener = _socket;
	unlock();

	if(!valid(listener)) return;
	trace(className() + "::listenSocket: Wait for connection...");
	Socket* newSocket = listener->accept();

	lock();
	if(newSocket == null)
	{
		// listening interrupted...socket closed?
		if(valid(_socket) && _socket->isConnected())
		{
			error(className()+"::listenSocket: Error on getting connection.");
		}
		else
		{
			trace(className() + "::listenSocket: Stop listening.");
			unlock();
			checkClosed();
			return;
		}
	}
	else
	{
		trace(className()+"::listenSocket: Incomming connection.");
		IConnection* newConnection = _builder->createConnection(newSocket);
		if(newConnection != null && _isClosed == false)
		{
			_connections.push(newConnection);

			newConnection->addEventListener(
				u::Network::Event::CLOSED
				, Callback(
					this, cb_cast(&WebListener::onConnectionClosed)
				)
			);

			WebEvent connectionCreated(
				WebEvent::INCOMMING_CONNECTION
				, (WebConnection*)newConnection
			);
			unlock();
			dispatchEvent(&connectionCreated);
			lock();
		}
		else
		{
			error(
				className()
				+ "::listenSocket: Can not etablish incomming conection"
			);
			newSocket->destroy();
		}
	}
	unlock();

	//self start ;)
	Callback cb(this, cb_cast(&WebListener::listenSocket));
	ThreadSystem::create(&cb);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5e0, %rsp            # imm = 0x5E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x417410
movq -0x520(%rbp), %rdi
movq 0x90(%rdi), %rax
movq %rax, -0x18(%rbp)
callq 0x417380
movq -0x18(%rbp), %rdi
callq 0x418ae0
testb $0x1, %al
jne 0x40cdbc
jmp 0x40d86b
movq $0x668c60, %rdi         # imm = 0x668C60
leaq 0x1ce2c7(%rip), %rsi    # 0x5db091
callq 0x49dd60
movq %rax, -0x528(%rbp)
movb $0x0, -0x91(%rbp)
movb $0x0, -0xa6(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40cdec
jmp 0x40ce22
movq -0x520(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x90(%rbp), %rdi
callq *%rax
movb $0x1, -0x91(%rbp)
leaq -0x58(%rbp), %rsi
leaq 0x1cec07(%rip), %rdx    # 0x5dba1c
leaq -0x38(%rbp), %rdi
callq 0x405d00
jmp 0x40ce20
jmp 0x40ce57
leaq -0xa5(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x435b90
movq -0x530(%rbp), %rdx
movb $0x1, -0xa6(%rbp)
leaq 0x1f3b58(%rip), %rsi    # 0x6009a2
leaq -0x38(%rbp), %rdi
callq 0x407e60
jmp 0x40ce55
jmp 0x40ce57
movq -0x528(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x538(%rbp)
jmp 0x40ce70
movq -0x538(%rbp), %rdi
leaq 0x1ce252(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x540(%rbp)
jmp 0x40ce8c
movq -0x540(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x40cea1
leaq -0x38(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0xa6(%rbp)
jne 0x40ceb5
jmp 0x40cec1
leaq -0xa5(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x91(%rbp)
jne 0x40cecc
jmp 0x40ced8
leaq -0x90(%rbp), %rdi
callq 0x405650
movq -0x18(%rbp), %rdi
callq 0x41c680
movq -0x520(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0x417410
cmpq $0x0, -0xb0(%rbp)
jne 0x40d326
movq -0x520(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x418ae0
testb $0x1, %al
jne 0x40cf1e
jmp 0x40d15d
movq -0x520(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x41aaf0
testb $0x1, %al
jne 0x40cf3a
jmp 0x40d15d
movq $0x668b40, %rdi         # imm = 0x668B40
leaq 0x1ce2d8(%rip), %rsi    # 0x5db220
callq 0x49dd60
movq %rax, -0x548(%rbp)
movb $0x0, -0x129(%rbp)
movb $0x0, -0x12b(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40cf6a
jmp 0x40cfa6
movq -0x520(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x128(%rbp), %rdi
callq *%rax
movb $0x1, -0x129(%rbp)
leaq -0xf0(%rbp), %rsi
leaq 0x1ceae8(%rip), %rdx    # 0x5dba7e
leaq -0xd0(%rbp), %rdi
callq 0x405d00
jmp 0x40cfa4
jmp 0x40cfde
leaq -0x12a(%rbp), %rdi
movq %rdi, -0x550(%rbp)
callq 0x435b90
movq -0x550(%rbp), %rdx
movb $0x1, -0x12b(%rbp)
leaq 0x1f39d4(%rip), %rsi    # 0x6009a2
leaq -0xd0(%rbp), %rdi
callq 0x407e60
jmp 0x40cfdc
jmp 0x40cfde
movq -0x548(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x558(%rbp)
jmp 0x40cffa
movq -0x558(%rbp), %rdi
leaq 0x1ce0c8(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x560(%rbp)
jmp 0x40d016
movq -0x560(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x40d02b
leaq -0xd0(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x12b(%rbp)
jne 0x40d042
jmp 0x40d04e
leaq -0x12a(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x129(%rbp)
jne 0x40d059
jmp 0x40d065
leaq -0x128(%rbp), %rdi
callq 0x405650
jmp 0x40d321
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d0c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d0ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0xa6(%rbp)
jne 0x40d0b8
jmp 0x40d0c4
leaq -0xa5(%rbp), %rdi
callq 0x435bb0
jmp 0x40d0c6
testb $0x1, -0x91(%rbp)
jne 0x40d0d1
jmp 0x40d0dd
leaq -0x90(%rbp), %rdi
callq 0x405650
jmp 0x40d892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d141
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d128
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x12b(%rbp)
jne 0x40d133
jmp 0x40d13f
leaq -0x12a(%rbp), %rdi
callq 0x435bb0
jmp 0x40d141
testb $0x1, -0x129(%rbp)
jne 0x40d14c
jmp 0x40d158
leaq -0x128(%rbp), %rdi
callq 0x405650
jmp 0x40d892
movq $0x668c60, %rdi         # imm = 0x668C60
leaq 0x1cdf26(%rip), %rsi    # 0x5db091
callq 0x49dd60
movq %rax, -0x568(%rbp)
movb $0x0, -0x1a9(%rbp)
movb $0x0, -0x1ab(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40d18d
jmp 0x40d1c9
movq -0x520(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x1a8(%rbp), %rdi
callq *%rax
movb $0x1, -0x1a9(%rbp)
leaq -0x170(%rbp), %rsi
leaq 0x1ce922(%rip), %rdx    # 0x5dbadb
leaq -0x150(%rbp), %rdi
callq 0x405d00
jmp 0x40d1c7
jmp 0x40d201
leaq -0x1aa(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x435b90
movq -0x570(%rbp), %rdx
movb $0x1, -0x1ab(%rbp)
leaq 0x1f37b1(%rip), %rsi    # 0x6009a2
leaq -0x150(%rbp), %rdi
callq 0x407e60
jmp 0x40d1ff
jmp 0x40d201
movq -0x568(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x578(%rbp)
jmp 0x40d21d
movq -0x578(%rbp), %rdi
leaq 0x1cdea5(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x580(%rbp)
jmp 0x40d239
movq -0x580(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x40d24e
leaq -0x150(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x1ab(%rbp)
jne 0x40d265
jmp 0x40d271
leaq -0x1aa(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x1a9(%rbp)
jne 0x40d27c
jmp 0x40d288
leaq -0x1a8(%rbp), %rdi
callq 0x405650
movq -0x520(%rbp), %rdi
callq 0x417380
movq -0x520(%rbp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
jmp 0x40d86b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d305
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d2ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x1ab(%rbp)
jne 0x40d2f7
jmp 0x40d303
leaq -0x1aa(%rbp), %rdi
callq 0x435bb0
jmp 0x40d305
testb $0x1, -0x1a9(%rbp)
jne 0x40d310
jmp 0x40d31c
leaq -0x1a8(%rbp), %rdi
callq 0x405650
jmp 0x40d892
jmp 0x40d802
movq $0x668c60, %rdi         # imm = 0x668C60
leaq 0x1cdd5d(%rip), %rsi    # 0x5db091
callq 0x49dd60
movq %rax, -0x588(%rbp)
movb $0x0, -0x229(%rbp)
movb $0x0, -0x22b(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40d356
jmp 0x40d392
movq -0x520(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x228(%rbp), %rdi
callq *%rax
movb $0x1, -0x229(%rbp)
leaq -0x1f0(%rbp), %rsi
leaq 0x1ce7ad(%rip), %rdx    # 0x5dbb2f
leaq -0x1d0(%rbp), %rdi
callq 0x405d00
jmp 0x40d390
jmp 0x40d3ca
leaq -0x22a(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0x435b90
movq -0x590(%rbp), %rdx
movb $0x1, -0x22b(%rbp)
leaq 0x1f35e8(%rip), %rsi    # 0x6009a2
leaq -0x1d0(%rbp), %rdi
callq 0x407e60
jmp 0x40d3c8
jmp 0x40d3ca
movq -0x588(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x598(%rbp)
jmp 0x40d3e6
movq -0x598(%rbp), %rdi
leaq 0x1cdcdc(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x5a0(%rbp)
jmp 0x40d402
movq -0x5a0(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x40d417
leaq -0x1d0(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x22b(%rbp)
jne 0x40d42e
jmp 0x40d43a
leaq -0x22a(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x229(%rbp)
jne 0x40d445
jmp 0x40d451
leaq -0x228(%rbp), %rdi
callq 0x405650
movq -0x520(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0xb0(%rbp), %rsi
movq (%rdi), %rax
callq *0x28(%rax)
movq %rax, -0x238(%rbp)
cmpq $0x0, -0x238(%rbp)
je 0x40d64c
movq -0x520(%rbp), %rax
movb 0xe8(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x40d64c
movq -0x520(%rbp), %rdi
addq $0x98, %rdi
movq -0x238(%rbp), %rsi
callq 0x40dce0
movq -0x520(%rbp), %rsi
movq -0x238(%rbp), %rax
movq %rax, -0x5b0(%rbp)
movq $0x0, -0x298(%rbp)
movq $0x49, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rdx
movq -0x298(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x290(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0x410a10
movq -0x5b0(%rbp), %rdi
movq -0x5a8(%rbp), %rdx
movq $0x667c80, %rsi         # imm = 0x667C80
callq 0x412620
jmp 0x40d523
leaq -0x290(%rbp), %rdi
callq 0x407e40
movq -0x238(%rbp), %rdx
movq $0x667788, %rsi         # imm = 0x667788
leaq -0x430(%rbp), %rdi
callq 0x40baf0
movq -0x520(%rbp), %rdi
callq 0x417380
jmp 0x40d557
movq -0x520(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x412820
jmp 0x40d56c
movq -0x520(%rbp), %rdi
callq 0x417410
jmp 0x40d57a
leaq -0x430(%rbp), %rdi
callq 0x40bbd0
jmp 0x40d800
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d5ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d5d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x22b(%rbp)
jne 0x40d5dc
jmp 0x40d5e8
leaq -0x22a(%rbp), %rdi
callq 0x435bb0
jmp 0x40d5ea
testb $0x1, -0x229(%rbp)
jne 0x40d5f5
jmp 0x40d601
leaq -0x228(%rbp), %rdi
callq 0x405650
jmp 0x40d892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x407e40
jmp 0x40d892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x40bbd0
jmp 0x40d892
movq $0x668b40, %rdi         # imm = 0x668B40
leaq 0x1cdbc6(%rip), %rsi    # 0x5db220
callq 0x49dd60
movq %rax, -0x5b8(%rbp)
movb $0x0, -0x4a9(%rbp)
movb $0x0, -0x4ab(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x40d67c
jmp 0x40d6b8
movq -0x520(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x4a8(%rbp), %rdi
callq *%rax
movb $0x1, -0x4a9(%rbp)
leaq -0x470(%rbp), %rsi
leaq 0x1ce4f2(%rip), %rdx    # 0x5dbb9a
leaq -0x450(%rbp), %rdi
callq 0x405d00
jmp 0x40d6b6
jmp 0x40d6f0
leaq -0x4aa(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x435b90
movq -0x5c0(%rbp), %rdx
movb $0x1, -0x4ab(%rbp)
leaq 0x1f32c2(%rip), %rsi    # 0x6009a2
leaq -0x450(%rbp), %rdi
callq 0x407e60
jmp 0x40d6ee
jmp 0x40d6f0
movq -0x5b8(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x4b05e0
movq %rax, -0x5c8(%rbp)
jmp 0x40d70c
movq -0x5c8(%rbp), %rdi
leaq 0x1cd9b6(%rip), %rsi    # 0x5db0d0
callq 0x49dd60
movq %rax, -0x5d0(%rbp)
jmp 0x40d728
movq -0x5d0(%rbp), %rdi
movq $0x49d640, %rsi         # imm = 0x49D640
callq 0x49c850
jmp 0x40d73d
leaq -0x450(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x4ab(%rbp)
jne 0x40d754
jmp 0x40d760
leaq -0x4aa(%rbp), %rdi
callq 0x435bb0
testb $0x1, -0x4a9(%rbp)
jne 0x40d76b
jmp 0x40d777
leaq -0x4a8(%rbp), %rdi
callq 0x405650
movq -0xb0(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
jmp 0x40d800
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d7e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x40d7cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x450(%rbp), %rdi
callq 0x4adc60
testb $0x1, -0x4ab(%rbp)
jne 0x40d7d6
jmp 0x40d7e2
leaq -0x4aa(%rbp), %rdi
callq 0x435bb0
jmp 0x40d7e4
testb $0x1, -0x4a9(%rbp)
jne 0x40d7ef
jmp 0x40d7fb
leaq -0x4a8(%rbp), %rdi
callq 0x405650
jmp 0x40d892
jmp 0x40d802
movq -0x520(%rbp), %rdi
callq 0x417380
movq -0x520(%rbp), %rsi
movq $0x0, -0x510(%rbp)
movq $0x41, -0x518(%rbp)
movq -0x518(%rbp), %rdx
movq -0x510(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x508(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0x410a10
movq -0x5d8(%rbp), %rdi
callq 0x41d040
jmp 0x40d85f
leaq -0x508(%rbp), %rdi
callq 0x407e40
addq $0x5e0, %rsp            # imm = 0x5E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x407e40
movq -0xa0(%rbp), %rdi
callq 0x4deb40
nop