Question about Sockets Programming
Hi
I am using recvfrom function to get data from the destination The underlying protocol for communication is UDP... Some times this function works properly while most of the times it causes segmentation faults. Following is my code char *rec_data=new char [800]; j=recvfrom(sourceDesc,rec_data,800,0,(struct sockaddr*)&Source,(socklen_t*)sizeof(Source)); I have been using this code since about 2 months now..and it never caused any problems...but now suddenly its malfunctioning |
The problem is probably your last parameter. recvfrom attempts to fill in that value with the size of your Source variable, but you are passing a pointer to a temporary variable... Try to change it like so:
Code:
char *rec_data=new char [800]; |
From recvfrom man page (about 6th parameter):
Quote:
|
All times are GMT -5. The time now is 02:20 AM. |