I am building a UDP chat app. Is it safe sending C struct over c socket and on the other end memset received data? All data in struct is nullpaded with memset, so I assume the size of the struct is always constant. What problems may I encounter?
How are more experienced programmers approaching this?
Yes it is safe BUT we should caveat this first. You may run into a problem if you are passing it between disparate platforms and then you need to worry about byte ordering/packing (amongst a host of other issues possibly). That being said, if you don’t know how to do any of this, then it is not safe to assume that you will reliably receive the
structin the same order you sent it.