data_size = recvfrom(sock_raw , buffer , 1024, 0 , &saddr ,
(socklen_t*)&saddr_size);
here is a recvfrom function, where i want to create a struct to 'saddr' and 'saddr_size' which is declared in the main() as follows
struct sockaddr saddr;
int saddr_size;
saddr_size = sizeof saddr;
and instead of buffer mentioned in the below write() api i have to use the struct variable.
int cont= write(logfile,buffer,data_size);
My question is: Below i have used structure.Is this the way to define struct for the following fields? Is it declared correctly? if not please somebody guide me to correct it.
struct data{
unsigned char buffer[1024];
unsigned long int saddr;
// struct sockaddr saddr;
int saddr_size;
};
struct data {
unsigned char buffer[1024];
struct sockaddr saddr;
socklen_t saddr_size;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With