segmentation fault while sending UDP packets!
The following piece of code is suppose to send a UDP packet.
but inside function udpsocketinit , i get a segmentation fault and i can not understand why!! please help me Code:
#include <arpa/inet.h> |
Try this:
Code:
int udpsocketinit(struct sockaddr_in *sok) |
Quote:
Quote:
Quote:
|
In main you declare a pointer to struct sockaddr_in (si_other) that is never initialized (so pointing to somewhere in memory). Next you try (in udpsockinit) to assign a value to an element of that struct so writing to memory that more than likely is not 'yours'.
|
bizoo,
I made some changes to my earlier post. They should fix your problems. However I have not tested them. Good luck. |
thanks all esp. David
Yup the problem indeed was initializing a pointer but not directing it to some struct |
All times are GMT -5. The time now is 04:12 PM. |