// File: BelfordZ[P]SimpleFileServer/Server.cpp
// Function: Server::Server()
Server::Server() 
{
   // Build queue with the port numbers. i starts at 30,000, and gets
   // even numbers up to 30,009
   for (int i = CLIENT_PORT_MIN; i < CLIENT_PORT_MAX; i+=2)
      portQ.push(i);

   try
   {
      std::cout << "Waiting for clients..." << std::endl;

      /*
	So, if we look in the S1 directory, you will see that this is
	how the server sockets work. You have to create a new socket
	which is bound to a port, and then you have to create a new
	"virgin socket" so that you can accept connections from the
	"slutty socket". We can then use the "virgin sockets" since
	they have been "sluttified".
      */
      
      client = new Socket(SERVER_DISPATCH_PORT);
      server = new Socket(CLIENT_DISPATCH_PORT);
      dispatchIn = new Socket();
      dispatchOut = new Socket();
   }
   catch (SocketException e)
   {
      std::cout << "ERROR:Server.cpp:Socket(): "
		<< "Failed to init Dispatch ports."
		<< std::endl;
   }
   
   currFrame = "";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x50(%rbp)
addq $0x20, %rdi
movq %rdi, -0x48(%rbp)
callq 0x3400
movl $0x7530, -0xc(%rbp)     # imm = 0x7530
cmpl $0x7539, -0xc(%rbp)     # imm = 0x7539
jge 0x3e84
leaq 0xc4ed(%rip), %rdi      # 0x10348
leaq -0xc(%rbp), %rsi
callq 0x4fc0
jmp 0x3e66
jmp 0x3e68
movl -0xc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xc(%rbp)
jmp 0x3e4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x40a5
movq 0xc14d(%rip), %rdi      # 0xffd8
leaq 0x71a6(%rip), %rsi      # 0xb038
callq 0x32c0
movq %rax, -0x58(%rbp)
jmp 0x3e9d
movq -0x58(%rbp), %rdi
movq 0xc118(%rip), %rsi      # 0xffc0
callq 0x3310
jmp 0x3eaf
movl $0x20, %edi
callq 0x32d0
movq %rax, -0x60(%rbp)
jmp 0x3ebf
movq -0x60(%rbp), %rdi
movl $0x9c40, %esi           # imm = 0x9C40
callq 0x98a0
jmp 0x3ecf
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0x20, %edi
callq 0x32d0
movq %rax, -0x68(%rbp)
jmp 0x3eeb
movq -0x68(%rbp), %rdi
movl $0x9c41, %esi           # imm = 0x9C41
callq 0x98a0
jmp 0x3efb
movq -0x50(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0x20, %edi
callq 0x32d0
movq %rax, -0x70(%rbp)
jmp 0x3f17
movq -0x70(%rbp), %rdi
callq 0x9860
jmp 0x3f22
movq -0x50(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movl $0x20, %edi
callq 0x32d0
movq %rax, -0x78(%rbp)
jmp 0x3f3d
movq -0x78(%rbp), %rdi
callq 0x9860
jmp 0x3f48
movq -0x50(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4068
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x3fd5
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x20, %esi
callq 0x32e0
jmp 0x3fd5
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x20, %esi
callq 0x32e0
jmp 0x3fd5
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x20, %esi
callq 0x32e0
jmp 0x3fd5
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x20, %esi
callq 0x32e0
movl -0x1c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x40a5
movq -0x18(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x33c0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x4ff0
jmp 0x4000
movq -0x80(%rbp), %rdi
callq 0x3130
movq 0xbfc8(%rip), %rdi      # 0xffd8
leaq 0x7038(%rip), %rsi      # 0xb04f
callq 0x32c0
movq %rax, -0x88(%rbp)
jmp 0x4025
movq -0x88(%rbp), %rdi
leaq 0x7038(%rip), %rsi      # 0xb06b
callq 0x32c0
movq %rax, -0x90(%rbp)
jmp 0x4041
movq -0x90(%rbp), %rdi
movq 0xbf71(%rip), %rsi      # 0xffc0
callq 0x3310
jmp 0x4056
leaq -0x40(%rbp), %rdi
callq 0x5020
callq 0x3460
jmp 0x4066
jmp 0x4068
movq -0x50(%rbp), %rdi
addq $0x20, %rdi
leaq 0x735b(%rip), %rsi      # 0xb3d2
callq 0x33f0
jmp 0x407e
addq $0x90, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5020
callq 0x3460
jmp 0x40a3
jmp 0x40a5
movq -0x48(%rbp), %rdi
callq 0x3548
movq -0x18(%rbp), %rdi
callq 0x3490
movq %rax, %rdi
callq 0x3de0
nop