APE_socket: fix fd leak + ape_shutdown() act as sync when dealing with server socket
buffer_append_string_n: now accept non null-terminated string
misc