mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-18 00:02:01 +00:00
IPv4: Implement bind() for TCP and UDP sockets.
We can't accept connections just yet, but this patch makes it possible to bind() to a given source address/port.
This commit is contained in:
parent
6a5d92f0ad
commit
abb5c890e0
Notes:
sideshowbarker
2024-07-19 14:17:40 +09:00
Author: https://github.com/awesomekling
Commit: abb5c890e0
6 changed files with 34 additions and 2 deletions
|
@ -203,3 +203,12 @@ bool TCPSocket::protocol_is_disconnected() const
|
|||
{
|
||||
return m_state == State::Disconnecting || m_state == State::Disconnected;
|
||||
}
|
||||
|
||||
KResult TCPSocket::protocol_bind()
|
||||
{
|
||||
LOCKER(sockets_by_port().lock());
|
||||
if (sockets_by_port().resource().contains(source_port()))
|
||||
return KResult(-EADDRINUSE);
|
||||
sockets_by_port().resource().set(source_port(), this);
|
||||
return KSuccess;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue