I do not know what you mean by device (any device located in /dev?), but here is a tutorial on c sockets using write and read:
https://vcansimplify.wordpress.com/2013/03/14/c-socket-tutorial-echo-server/
If you would like to gain access to a device in /dev then you just need to open it like a file and also treat it like a file (read / write from it like you would from a file).
1
solved Connect, read, write to a device using TCP/IP in C [closed]