// File: /workspace/github_cpp_makefile_star2_O2/nickgammon[P]tinymudserver/comms.cpp
// Function: ProcessNewConnection()
void ProcessNewConnection ()
  {
  static struct sockaddr_in sa;
  socklen_t sa_len = sizeof sa;   

  int s;    /* incoming socket */

  /* loop until all outstanding connections are accepted */
  while (true)
    {
    s = accept ( iControl, (struct sockaddr *) &sa, &sa_len);

    /* a bad socket probably means no more connections are outstanding */
    if (s == NO_SOCKET)
      {

      /* blocking is OK - we have accepted all outstanding connections */
      if ( errno == EWOULDBLOCK )
        return;

      perror ("accept");
      return;
      }
        
    /* here on successful accept - make sure socket doesn't block */
    
    if (fcntl (s, F_SETFL, FNDELAY) == -1)
      {
      perror ("fcntl on player socket");
      return;
      }

    string address = inet_ntoa ( sa.sin_addr);
    int port = ntohs (sa.sin_port);
            
    // immediately close connections from blocked IP addresses
    if (blockedIP.find (address) != blockedIP.end ())
      {
      cerr << "Rejected connection from " << address << endl;
      close (s);
      continue;      
      }
      
    tPlayer * p = new tPlayer (s, port, address);
    playerlist.push_back (p);
    
    cout << "New player accepted on socket " << s << 
            ", from address " << address << 
            ", port " << port << endl;
      
    *p << "\nWelcome to the Tiny MUD Server version " << VERSION << "\n"; 
    *p << messagemap ["welcome"];   // message from message file
    *p << p->prompt;    // initial prompt (Enter your name ...)
    
    } /* end of processing *all* new connections */

  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq -0x3c(%rbp), %rax
movl $0x10, (%rax)
leaq -0xa8(%rbp), %r13
leaq 0x908f(%rip), %rax      # 0x14948
addq $0x8, %rax
movq %rax, -0x48(%rbp)
leaq 0x8a38(%rip), %rax      # 0x14300
movl (%rax), %edi
leaq 0x916f(%rip), %rsi      # 0x14a40
leaq -0x3c(%rbp), %rdx
callq 0x3100
cmpl $-0x1, %eax
je 0xba9f
movl %eax, %r12d
movl %eax, %edi
pushq $0x4
popq %rsi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x31f0
cmpl $-0x1, %eax
je 0xbabb
movl 0x913e(%rip), %edi      # 0x14a44
callq 0x3170
movq %r13, %rdi
movq %rax, %rsi
leaq -0x68(%rbp), %rdx
callq 0x43b6
movzwl 0x9120(%rip), %r14d     # 0x14a42
leaq 0x901f(%rip), %rdi      # 0x14948
movq %r13, %rsi
callq 0xc278
cmpq -0x48(%rbp), %rax
je 0xb96a
movq 0x86aa(%rip), %rdi      # 0x13fe8
leaq 0x211c(%rip), %rsi      # 0xda61
callq 0x3310
movq %rax, %rdi
movq %r13, %rsi
callq 0x32e0
movq %rax, %rdi
callq 0x31a0
movl %r12d, %edi
callq 0x35a0
jmp 0xba92
movl $0x110, %edi            # imm = 0x110
callq 0x3320
movq %rax, %r15
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3400
rolw $0x8, %r14w
movzwl %r14w, %r14d
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
movq %rbx, %rcx
callq 0xbdfa
movq %rbx, %rdi
callq 0x35c8
movq %r15, -0x38(%rbp)
leaq 0x8e5a(%rip), %rdi      # 0x14810
leaq -0x38(%rbp), %rsi
callq 0xbf44
movq 0x85fa(%rip), %rdi      # 0x13fc0
leaq 0x20ae(%rip), %rsi      # 0xda7b
callq 0x3310
movq %rax, %rdi
movl %r12d, %esi
callq 0x34f0
movq %rax, %rdi
leaq 0x20b3(%rip), %rsi      # 0xda9a
callq 0x3310
movq %rax, %rdi
movq %r13, %rsi
callq 0x32e0
movq %rax, %rdi
leaq 0x20a9(%rip), %rsi      # 0xdaaa
callq 0x3310
movq %rax, %rdi
movl %r14d, %esi
callq 0x34f0
movq %rax, %rdi
callq 0x31a0
movq -0x38(%rbp), %rdi
leaq 0x208e(%rip), %rsi      # 0xdab2
callq 0xbf54
movq %rax, %rdi
leaq 0x8f4d(%rip), %rsi      # 0x14980
callq 0x5e24
movq %rax, %rdi
leaq 0x1692(%rip), %rsi      # 0xd0d4
callq 0x92f2
movq -0x38(%rbp), %r14
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
leaq 0x2082(%rip), %rsi      # 0xdadb
leaq -0x29(%rbp), %rdx
callq 0x43b6
leaq 0x8e4f(%rip), %rdi      # 0x148b8
movq %rbx, %rsi
callq 0x6792
movq %r14, %rdi
movq %rax, %rsi
callq 0x5e24
leaq -0x68(%rbp), %rdi
callq 0x35c8
movq -0x38(%rbp), %rdi
leaq 0x70(%rdi), %rsi
callq 0x5e24
movq %r13, %rdi
callq 0x35c8
jmp 0xb8c1
callq 0x3040
cmpl $0xb, (%rax)
jne 0xbac4
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f88(%rip), %rdi      # 0xda4a
jmp 0xbacb
leaq 0x1f78(%rip), %rdi      # 0xda43
callq 0x32a0
jmp 0xbaa9
jmp 0xbb09
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x35c8
jmp 0xbae8
movq %rax, %rbx
movl $0x110, %esi            # imm = 0x110
movq %r15, %rdi
callq 0x3330
jmp 0xbb0c
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x35c8
jmp 0xbb0c
jmp 0xbb09
jmp 0xbb09
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x35c8
movq %rbx, %rdi
callq 0x3500