Hi, I am trying to test one small program in which...the program is not listing the devices that are present in the remote machine. (it keeps waiting there).
Attached codes : 1.main.cpp 2.server.c (Simple C socket server program) while executing I have done the following steps 1.Started the server by executing server.c(with some port eg.9898 as an argument) 2.Started the daemon rpcapd.exe -b 127.0.0.1 -p 9898 -n ( since the server is executing in the local machine) 3. Started the execution of main program Out put : Enter the device you want to list: rpcap:// ==> lists interfaces in the local machine rpcap://hostname:port ==> lists interfaces in a remote machine (rpcapd daemon must be up and running and it must accept 'null' authentication) file://foldername ==> lists all pcap files in the give folder Enter your choice: rpcap://127.0.0.1:9898/ After this step it keeps on waiting ..and does not display any devices on this machine with this port? And also at the server side I see that connection is accepted(becz I see the conn accept msg) So do I have to include any code on the server program to send the device list or it should automatically detect the devices?? So any help on this would be really useful to me .... Thanks in advance, Vishwesh
main.cpp
Description: Binary data
/* CHANGES FROM UNIX VERSION */
/* */
/* 1. Changed header files */
/* 2. Added WSAStartUP() and WSACleanUp(). */
#define HAVE_REMOTE
#include "pcap.h"
#include <stdio.h> /* for printf(), fprintf() */
#include <winsock2.h> /* for socket(),... */
#include <stdlib.h> /* for exit() */
#define MAXPENDING 5 /* Maximum outstanding connection requests */
main(int argc, char *argv[])
{
int servSock; /* Socket descriptor for server */
int clntSock; /* Socket descriptor for client */
struct sockaddr_in echoServAddr; /* Local address */
struct sockaddr_in echoClntAddr; /* Client address */
unsigned short echoServPort; /* Server port */
int clntLen; /* Length of client address data structure */
WSADATA wsaData; /* Structure for WinSock setup communication */
if (argc != 2) /* Test for correct number of arguments */
{
fprintf(stderr, "Usage: %s <Server Port>\n", argv[0]);
exit(1);
}
echoServPort = atoi(argv[1]); /* first arg: Local port */
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */
{
fprintf(stderr, "WSAStartup() failed");
exit(1);
}
/* Create socket for incoming connections */
if ((servSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
printf("socket() failed");
/* Construct local address structure */
memset(&echoServAddr, 0, sizeof(echoServAddr)); /* Zero out structure */
echoServAddr.sin_family = AF_INET; /* Internet address family */
echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
echoServAddr.sin_port = htons(echoServPort); /* Local port */
/* Bind to the local address */
if (bind(servSock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0)
printf("bind() failed");
/* Mark the socket so it will listen for incoming connections */
if (listen(servSock, MAXPENDING) < 0)
printf("listen() failed");
for (;;) /* Run forever */
{
/* Set the size of the in-out parameter */
clntLen = sizeof(echoClntAddr);
/* Wait for a client to connect */
if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen)) < 0)
printf("accept() failed");
/* clntSock is connected to a client! */
printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr));
//HandleTCPClient(clntSock);
}
/* NOT REACHED */
}
_______________________________________________ Winpcap-users mailing list [email protected] https://www.winpcap.org/mailman/listinfo/winpcap-users
