If you have to deal with raw sockets, I highly recommend libtins: https://github.com/mfontanini/libtins Makes it very easy to support multiple platforms.
I recently had do support for a Digidesign Pro Control (https://medias.audiofanzine.com/images/normal/digidesign-pro...) that used it's own ethernet protocol. Libtins made it very easy and I didn't need to write my own driver or anything like that.