How would I copy a structure into shared memory on Unix? The structure is below:
struct share_weather *weatherPTR ; // point to the shared weather structureCode:struct sh_weather { float intemp_F; // indoor temperature in Fahrenheit float intemp_C; // indoor temperature in Celsius float outtemp_F; // Outdoor temperature in Fahrenheit float outtemp_C; // outdoor temp in Celsius unchar w_speed; // Wind Speed in MPH char *wind_d; // String pointing to wind direction buffer float inbaro; // Inches of Mercury float mmbaro; // Mercury in MM unchar out_hum; // Outside Humidity unchar in_hum; // Inside Humidity float t_rain; // Total rain since weather system reset } share_weather;
do I use mmap()?
also how do I typedef a pointer to the structure to update the data fields inside it
I got a shared memory chunk with this:
kinda lost after thatCode:shm_id = shmget(key, sizeof(share_data), IPC_CREAT | 0644); // Give only Read permission to Clients if (shm_id < 0) { printf("Problem getting shared memory segment using key %d\n", key); exit(1); }
thanks



LinkBack URL
About LinkBacks


