Below program recieves/captures the packet from the internet and writes into a file (logfile). In my other program i use read() func instead of recvfrom(),but just sending the the buffer doesn't process the packets correctly. Hence i thought of sending two more fields which are in the recvfrom function
int main()
{
int saddr_size,data_size;
struct sockaddr saddr;
unsigned char *buffer = (unsigned char *) malloc(1024);
while(1)
{
saddr_size = sizeof saddr;
//Receive a packet
data_size = recvfrom(sock_raw , buffer , 1024, 0 , &saddr ,(socklen_t*)&saddr_size);
int cont= write(logfile,buffer,data_size);
}
return 0;
}
In the above program, i need to define structure to &saddr and (socklen_t*)&saddr_size). that is instead of sending just the buffer i need to send value of &saddr and (socklen_t*)&saddr_size). How can i do it?i mean to say how to define struct to &sddr and (socklen_t*)&saddr_size)?? please somebody guide me.