Thank you for reading this, I appreciate any help!
I don't really seem to find an answer that satisfies the following questions, mostly explained unclearly. Imagine I'd create a socket object in Python:
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Then, I'd like to set the options of that socket object (server), with the following three arguments.
socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
I'm kind of confused by these arguments. Firstly, the SOL_SOCKET, is it some kind of constant value that actually allows the following arguments in the signature (like reuseaddr) to implement it on the socket level? (More info is welcome)
Secondly the REUSEADDR what does it actually do? It allows the server to reuse (accept connections) the same ip and port, while it's in close-wait or time-wait state. If that's correct, I don't seem to get why that is needed, can't I just keep accepting connections on the same port and ip, without using it, isn't that setting automatically used, it would be my best guess that you can have multiple connections on a single port and ip address without using that argument?
Finally, what does the 1
mean at the end?
The primary reason I'm asking this question because I thought if I wouldn't use REUSEADDR that I could still accept other connections on the same port and ip
Thank you for the help, have a great day!