mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
IPv4: Basic implementation of TCP socket shutdown
We can now participate in the TCP connection closing handshake. :^) This implementation is definitely not complete and needs to handle a bunch of other cases. But it's a huge improvement over not being able to close connections at all. Note that we hold on to pending-close sockets indefinitely, until they are moved into the Closed state. This should also have a timeout but that's still a FIXME. :^) Fixes #428.
This commit is contained in:
parent
8325662186
commit
228a1e9099
7 changed files with 69 additions and 8 deletions
|
@ -155,12 +155,16 @@ public:
|
|||
static RefPtr<TCPSocket> from_tuple(const IPv4SocketTuple& tuple);
|
||||
static RefPtr<TCPSocket> from_endpoints(const IPv4Address& local_address, u16 local_port, const IPv4Address& peer_address, u16 peer_port);
|
||||
|
||||
static Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& closing_sockets();
|
||||
|
||||
RefPtr<TCPSocket> create_client(const IPv4Address& local_address, u16 local_port, const IPv4Address& peer_address, u16 peer_port);
|
||||
void set_originator(TCPSocket& originator) { m_originator = originator.make_weak_ptr(); }
|
||||
bool has_originator() { return !!m_originator; }
|
||||
void release_to_originator();
|
||||
void release_for_accept(RefPtr<TCPSocket>);
|
||||
|
||||
virtual void close() override;
|
||||
|
||||
protected:
|
||||
void set_direction(Direction direction) { m_direction = direction; }
|
||||
|
||||
|
@ -170,6 +174,8 @@ private:
|
|||
|
||||
static NetworkOrdered<u16> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, u16 payload_size);
|
||||
|
||||
virtual void shut_down_for_writing() override;
|
||||
|
||||
virtual int protocol_receive(const KBuffer&, void* buffer, size_t buffer_size, int flags) override;
|
||||
virtual int protocol_send(const void*, size_t) override;
|
||||
virtual KResult protocol_connect(FileDescription&, ShouldBlock) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue