Closed nemasu closed 7 years ago
Do we need to use a shutdown before the sys_close call?
Ah my bad, I think instead of using shutdown, we just need to add the flag SO_REUSEADDR to the bind port.
So we will need a new syscall to SYS_SETSOCKOPT with rdx = SO_REUSEADDR after sys_create_tcp_socket.
The pointer to 1 might be an issue as the stack isn't setup the same as it is for the cork syscalls so may need to make use of some r registers to save the rbp/rsp?
I've changed it to use bss data instead of stack, and it's calling the correct functions successfully (SO_REUSEADDR), but I still get the bind error when I close it after a client connects.
Ah, I figured it out, need to call REUSEADDR before bind, not after. :)
Listening socket isn't closed when program exists.