Function at 0x402140
Capabilities:
Create tcp socket
Create udp socket
Get socket status
Set socket configuration
Start tcp server
Terminate process

Disassembly:
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 0x4c
movzx ebx, word [ebp + 8]
mov dword [esp], str.Creating_source_port_to_forward._n
call fcn.004020e0
mov dword [esp + 8], 0
mov dword [esp + 4], 1
mov dword [esp], 2
call sub.cygwin1.dll_socket
test eax, eax
mov dword [0x4071ec], eax
js 0x40236f
lea eax, [ebp - 0x14]
mov dword [ebp - 0x14], 1
mov dword [esp + 0xc], eax
mov eax, dword [0x4071ec]
mov dword [esp + 0x10], 4
mov dword [esp + 8], 4
mov dword [esp + 4], 0xffff
mov dword [esp], eax
call sub.cygwin1.dll_setsockopt
mov eax, ebx
movzx ebx, bx
xchg ah, al
mov word [ebp - 0x2a], ax
lea eax, [ebp - 0x2c]
mov dword [ebp - 0x28], 0
mov word [ebp - 0x2c], 2
mov dword [esp + 4], eax
mov eax, dword [0x4071ec]
mov dword [esp + 8], 0x10
mov dword [esp], eax
call sub.cygwin1.dll_bind
test eax, eax
js 0x40238b
mov eax, dword [0x4071ec]
mov dword [esp + 4], 1
mov dword [esp], eax
call sub.cygwin1.dll_listen
test eax, eax
js 0x402353
mov eax, dword [0x4071ec]
lea esi, [ebp - 0x1c]
mov dword [esp + 4], ebx
lea ebx, [ebp - 0x14]
mov dword [esp], str.waiting_new_connection_at_port__d__socket_d__n
mov dword [esp + 8], eax
call fcn.004020e0
mov eax, dword [0x4071ec]
mov edi, eax
mov dword [ebp - 0x40], eax
add edi, 1
lea esi, [esi]
mov eax, esi
mov byte [eax], 0
add eax, 1
cmp eax, ebx
jne 0x402242
mov edx, dword [ebp - 0x40]
mov eax, 1
and dword [ebp - 0x40], 0x1f
movzx ecx, byte [ebp - 0x40]
shr edx, 5
shl eax, cl
or dword [ebp + edx*4 - 0x1c], eax
or dword [ebp - 0x1c], 1
mov dword [esp + 0x10], 0
mov dword [esp + 0xc], 0
mov dword [esp + 8], 0
mov dword [esp + 4], esi
mov dword [esp], edi
call sub.cygwin1.dll_select
cmp eax, 0xffffffff
je 0x402330
test eax, eax
jg 0x4022a4
mov eax, dword [0x4071ec]
mov dword [ebp - 0x40], eax
jmp 0x402240
test byte [ebp - 0x1c], 1
jne 0x402301
mov ecx, dword [0x4071ec]
mov eax, ecx
mov edx, ecx
shr eax, 5
and edx, 0x1f
mov eax, dword [ebp + eax*4 - 0x1c]
mov dword [ebp - 0x40], ecx
mov ecx, edx
sar eax, cl
test al, 1
je 0x402240
lea eax, [ebp - 0x10]
mov dword [ebp - 0x10], 0x10
mov dword [esp + 8], eax
lea eax, [ebp - 0x3c]
mov dword [esp + 4], eax
mov eax, dword [ebp - 0x40]
mov dword [esp], eax
call sub.cygwin1.dll_accept
test eax, eax
mov ebx, eax
js 0x4023a7
add esp, 0x4c
mov eax, ebx
pop ebx
pop esi
pop edi
pop ebp
ret
call sub.cygwin1.dll___getreent
mov eax, dword [eax + 4]
mov dword [esp], eax
call sub.cygwin1.dll_getc
test eax, eax
jg 0x4022aa
mov dword [esp], str.Give_up_waiting_port_because_stdin_is_closed.
call fcn.004020e0
mov dword [esp], 0
call sub.cygwin1.dll_exit
lea esi, [esi]
call sub.cygwin1.dll___errno
mov eax, dword [eax]
mov dword [esp], str.select___failed___d_n
mov dword [esp + 4], eax
call fcn.00401870
mov dword [esp], 1
call sub.cygwin1.dll_exit
call sub.cygwin1.dll___errno
mov eax, dword [eax]
mov dword [esp], str.listen___failed__errno_d_n
mov dword [esp + 4], eax
call fcn.00401870
jmp 0x40220e
call sub.cygwin1.dll___errno
mov eax, dword [eax]
mov dword [esp], str.socket___failed__errno_d_n
mov dword [esp + 4], eax
call fcn.00401870
jmp 0x402182
call sub.cygwin1.dll___errno
mov eax, dword [eax]
mov dword [esp], str.bind___failed__errno_d_n
mov dword [esp + 4], eax
call fcn.00401870
jmp 0x4021f1
call sub.cygwin1.dll___errno
mov eax, dword [eax]
mov dword [esp], str.accept___failed__errno_d_n
mov dword [esp + 4], eax
call fcn.00401870
add esp, 0x4c
mov eax, ebx
pop ebx
pop esi
pop edi
pop ebp
ret