소켓 accept()에서 컴파일 에러.....

익명 사용자의 이미지

#include
#include
#include
#include
#include
#include
#include
#include

struct sockaddr_in tcpServer, tcpClient;
int tcpsd,tcpns, tcpClientlen = sizeof
(tcpClient);
int
main(int argc, char* argv[])
{
.....
.....

if( (tcpns = accept(tcpsd,(struct sockaddr *)&tcpClient,
&tcpClientlen)) < 0 )
{
perror("TCP accept error...\n");
return -1;
}
..........
..........
}
이렇게 사용하고 컴파일 하면 accept(,,)에서
invalid conversion from `int*' to `socklen_t*'
이라고 에러가 나옵니다.

Sun Solaris8, gcc3.1을 사용하고 있습니다.

뭘잘못 사용했나요?

익명 사용자의 이미지

if( (tcpns = accept(tcpsd,(struct sockaddr *)&tcpClient,
&tcpClientlen)) < 0 )

타입 캐스팅 에러군요. 에러를 보시면 다음과 같이

invalid conversion from `int*' to `socklen_t*

int * 형을 socklen_t * 형으로 바꾸니깐 잘못된거다 하고 나오죠

그럼 &tcpClientlen 을 다음과 같이 타입 캐스팅을 해주시면 됩니다.

(socklen_t *)&tcpClientlen

그럼 고운 하루되세요.

고마워요 wrote..
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <wait.h>

struct sockaddr_in tcpServer, tcpClient;
int tcpsd,tcpns, tcpClientlen = sizeof
(tcpClient);
int
main(int argc, char* argv[])
{
.....
.....

if( (tcpns = accept(tcpsd,(struct sockaddr *)&tcpClient,
&tcpClientlen)) < 0 )
{
perror("TCP accept error...\n");
return -1;
}
..........
..........
}
이렇게 사용하고 컴파일 하면 accept(,,)에서
invalid conversion from `int*' to `socklen_t*'
이라고 에러가 나옵니다.

Sun Solaris8, gcc3.1을 사용하고 있습니다.

뭘잘못 사용했나요?