mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
Add support for socket send/receive timeouts.
Only the receive timeout is hooked up yet. You can change the timeout by calling setsockopt(..., SOL_SOCKET, SO_RCVTIMEO, ...). Use this mechanism to make /bin/ping report timeouts.
This commit is contained in:
parent
7bcd386338
commit
562663df7c
12 changed files with 212 additions and 12 deletions
|
@ -38,13 +38,22 @@ public:
|
|||
virtual ssize_t sendto(const void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
|
||||
virtual ssize_t recvfrom(void*, size_t, int flags, const sockaddr*, socklen_t) = 0;
|
||||
|
||||
KResult setsockopt(int level, int option, const void*, socklen_t);
|
||||
KResult getsockopt(int level, int option, void*, socklen_t*);
|
||||
|
||||
pid_t origin_pid() const { return m_origin_pid; }
|
||||
|
||||
timeval receive_deadline() const { return m_receive_deadline; }
|
||||
timeval send_deadline() const { return m_send_deadline; }
|
||||
|
||||
protected:
|
||||
Socket(int domain, int type, int protocol);
|
||||
|
||||
KResult queue_connection_from(Socket&);
|
||||
|
||||
void load_receive_deadline();
|
||||
void load_send_deadline();
|
||||
|
||||
private:
|
||||
Lock m_lock;
|
||||
pid_t m_origin_pid { 0 };
|
||||
|
@ -54,6 +63,12 @@ private:
|
|||
int m_backlog { 0 };
|
||||
bool m_connected { false };
|
||||
|
||||
timeval m_receive_timeout { 0, 0 };
|
||||
timeval m_send_timeout { 0, 0 };
|
||||
|
||||
timeval m_receive_deadline { 0, 0 };
|
||||
timeval m_send_deadline { 0, 0 };
|
||||
|
||||
Vector<RetainPtr<Socket>> m_pending;
|
||||
Vector<RetainPtr<Socket>> m_clients;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue