M
manochavishal
Hi,
I am having strange problem in my Program.
I cannot paste the whole program as it is huge so just pasting the
lines i think are necessary.
I am passing a integer array pointer to a function.
**********
int sockets[MAX_TCPCLIENTS]; /* an array of connected sockets*/
......
......
fprintf(stderr,"The value is %d",sockets);
accept_new_tcp_client(sockets,&readset,listenfd);
.......
.......
void accept_new_tcp_client(int *sockets, fd_set *readset, int listenfd)
{
struct sockaddr *signaddr;
int addrlength;
int i;
int clientsockfd;
addrlength = sizeof(signaddr);
fprintf(stderr,"\nThe value is %d",sockets);
/*== First accept the new connection ==*/
if((clientsockfd = accept(listenfd,(struct
sockaddr*)&signaddr,&addrlength))<0)
{
printf("\nSome Problem with accepting connection");
exit(EXIT_FAILURE);
}
fprintf(stderr,"\nAccepted a new Client connection");
fprintf(stderr,"\nThe value is %d",sockets);
********
The print output is
.....
The value is 12643936
The value is 12643936
Accepted a new Client connection
The value is 0Segmentation fault (core dumped)
Can anyone explians whats happening???
Cheers
Vishal
I am having strange problem in my Program.
I cannot paste the whole program as it is huge so just pasting the
lines i think are necessary.
I am passing a integer array pointer to a function.
**********
int sockets[MAX_TCPCLIENTS]; /* an array of connected sockets*/
......
......
fprintf(stderr,"The value is %d",sockets);
accept_new_tcp_client(sockets,&readset,listenfd);
.......
.......
void accept_new_tcp_client(int *sockets, fd_set *readset, int listenfd)
{
struct sockaddr *signaddr;
int addrlength;
int i;
int clientsockfd;
addrlength = sizeof(signaddr);
fprintf(stderr,"\nThe value is %d",sockets);
/*== First accept the new connection ==*/
if((clientsockfd = accept(listenfd,(struct
sockaddr*)&signaddr,&addrlength))<0)
{
printf("\nSome Problem with accepting connection");
exit(EXIT_FAILURE);
}
fprintf(stderr,"\nAccepted a new Client connection");
fprintf(stderr,"\nThe value is %d",sockets);
********
The print output is
.....
The value is 12643936
The value is 12643936
Accepted a new Client connection
The value is 0Segmentation fault (core dumped)
Can anyone explians whats happening???
Cheers
Vishal