Antonio de Angelis wrote:
Hi all,
I am working with the Win32 port. My question is, when i create a
listening server on a specific port, how can I refuse an incoming
connection on that port? For example, if I want to refuse the
connection from a specific remote IP address,
lwIP does not have the ability to selectively only establish certain TCP
connections and not others. So you won't be able to selectively have
"connection refused" sent to an unwanted remote IP.
But there's nothing stopping you immediately closing the connection as
soon as a connection was accepted, after you've looked at who the peer
address is. That's probably good enough.
or if i want to refuse the connection in case that there are too much
active connections on the server. Thank you
That case is different - denying everybody, rather than denying
selectively. In which case you could temporarily remove your listening
socket entirely. However because lwIP doe snot have SOREUSEADDR, it's
probably safer not to, otherwise you might have difficulty recreating
the socket reliably when things are back to normal again. So again maybe
it's still better to just close unwanted connections after they're
accepted.
Jifl