c언어 send recv 질문
글쓴이: 익명 사용자 / 작성시간: 일, 2018/02/04 - 10:19오전
//server
typedef struct {
int client_id;
char client_ip[16];
char client_cnttime[30];
}clientinfo;
clientinfo clntInfo[10];
//**** 위 내용의 구조체를 보냈습니다.
send(clnt_sock, (char*)&clntInfo[clnt_id],sizeof(clntInfo[clnt_id]),0);//client
typedef struct {
int client_id;//8
char client_ip[16];
char client_cnttime[30];
}clientinfo;
clientinfo clntInfo[1];
retval = recv(sock,(char*)&clntInfo[clnt_id],60,0);
clntInfo[1] = clntInfo[clnt_id];
printf("%d\t %s\t %s\n",clntInfo[1].client_id,clntInfo[1].client_ip,clntInfo[1].client_cnttime);
//잘 들어갔는지 확인용...recv 함수를 저렇게 만들어 봤는데 값이 안들어가서 찾아봤지만 잘 모르겠습니다.
본론 : 구조체를 받는법과 출력하는 방법을 알고 싶습니다.
Forums:

음..
실제 전송 여부를 떠나서 '클라이언트' 라고 부르는 쪽 clntInfo[1] 에 뭔가 들어있을거라는 기대를 하시면 안됩니다.
이 부분이 이해가 안되시면 배열의 선언과 범위에 대해서 다시 복습하시고 구조체를 살피시면 되겠습니다.
소곤소곤
client에서
client에서
clntInfo[1].client_id ==> 배열의 시작은 0 입니다.
댓글 달기