# Monitor socket FD

**URL:** <https://forum.legato.io/t/monitor-socket-fd/6681>\
**Category:** Uncategorized\
**Created:** [January 8, 2024, 6:02pm UTC](https://forum.legato.io/t/monitor-socket-fd/6681 "2024-01-08T18:02:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gi1](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@gi1](https://forum.legato.io/u/gi1)\
**Post date:** [January 8, 2024, 6:02pm UTC](https://forum.legato.io/t/monitor-socket-fd/6681/1 "2024-01-08T18:02:57Z")

</div>

Hello,  
to monitor a socket in case of error or disconnection is this the right way:

le\_fdMonitor\_Create(“SockMon”, // Name for diagnostics  
sockFD, // fd to monitor  
SocketStateHandler, // Handler function  
POLLIN |POLLOUT | POLLRDHUP );

I’m not sure on bitwise (last parameter) to set…

regards,  
Gianmaria

---

<div class="post-metadata">

**Author:** ![gi1](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@gi1](https://forum.legato.io/u/gi1)\
**Post date:** [January 8, 2024, 6:06pm UTC](https://forum.legato.io/t/monitor-socket-fd/6681/2 "2024-01-08T18:06:21Z")

</div>

Dont care…

The following events are always monitored, even if not requested:

- `POLLRDHUP` = Other end of stream socket closed or shutdown.
- `POLLERR` = Error occurred.
- `POLLHUP` = Hang up.

It’s enough for me.
