건물 서버와 클라이언트 프로그램을 구축 중입니다. 나는 그들이 소켓을 통해 통신하도록 노력하고있다. (32 비트 OS 리눅스에서 쓰고 클라이언트와 서버가 같은 시스템에서 실행되는 것이 중요하다면). 지금, 나는 다음 구조체가 :소켓을 통해 구조체를 보내고 해당 구조체에 액세스 할 때 segfaulting
struct config configData; // global
을 followes 나는 보낼를 configdata가 정의
struct config_line {
char name[MAX_WORD]; //1 byte
int time; //4 bytes
};
struct config {
struct config_line *lines; // 4 bytes, points to a struct of 8 bytes
int count; // 4 bytes
};
을 그를 configdata이 같은 :
send (clients [scn], &configData, sizeof (configData), 0)
이제 내 클라이언트 프로그램, 내부 때 액세스를 시도하십시오
configData.lines[configIndex].name
그 줄에 segfaults. 누구나 이유가 무엇입니까? 이 유형 config
를 보낼 때
recv (s, & configData, sizeof (configData), 0); –