UDP Broadcast

Could someone help me with sample code for UDP Broadcast.
I have read about sending data to whole subnet, but can’t find a method for that.
When I try to connect to “192.168.1.255” it trows an error.
I have tried SetEnableBroadcast method – get the same.