Hello,
I am a new user of tcpdump. I found that if the server and client
application run on the same machine, tcpdump cannot catch the packets
transferred between them. Can anyone tell me the reason? Any suggestions
will be appreciated.
The following is part of the test programs I used:
//--------TCP server--------------------------
struct hostent *hostinfo;
struct sockaddr_in listener;
lsockFd = socket(AF_INET, SOCK_STREAM, 0);
listener.sin_family = AF_INET;
listener.sin_addr = **(struct in_addr **)hostinfo->h_addr_list;
listener.sin_port=0;
if (bind(lsockFd, (struct sockaddr *)&listener, sizeof(listener))<0){
perror("bind listen:"); exit(1);
}
size=sizeof(listener);
getsockname(lsockFd,(struct sockaddr*)&listener,(socklen_t *)&size);
listen(lsockFd,10);
// write information to a file so that the client can know the server
information
while(1){
length = sizeof(from_tcp);
tmpsock = accept(lsockFd,(struct sockaddr *)&from_tcp,&length);
forkret_tcp = fork();
if (forkret_tcp<0){ perror("Fork"); exit(-1);}
if (forkret_tcp == 0) {
close(lsockFd);
tcp_procedure (tmpsock);
exit(0);
}
....
}
//-----------TCP client-----------
struct sockaddr_in listener;
// read server information from the file, so that listener has
appropriate value
qfd = socket(AF_INET,SOCK_STREAM,0);
if (connect(qfd,&listener,sizeof(listener))<0)
perror("connect:");exit(1);}
FD_ZERO(&mask); FD_SET(qfd, &mask);
timeout.tv_sec = 20;
timeout.tv_usec = 0;
if ((hits = select(qfd+1, (fd_set *)0, &mask,(fd_set *)0, &timeout)) <
0) {
perror("client: TCP/IP select"); exit(1);
}
....
thanks
Chunhua
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe