Hi,
I am working on a little client application that uses sockets to connect to the kismet server running on this router. On my Laptop, the following code works. But compiled for OpenWRT it doesnt
[...]
int create_socket;
char * buffer = (char*) malloc (BUF);
struct sockaddr_in address;
int size;
if ((create_socket = socket (AF_INET, SOCK_STREAM, 0)) > 0)
printf ("PacketReader: Socket wurde angelegt\n");
else
return 0;
address.sin_family = AF_INET;
address.sin_port = htons (2501);
inet_aton ("127.0.0.1", &address.sin_addr);
if (connect ( create_socket, (struct sockaddr *) &address, sizeof (address)) == 0) {
printf("PacketReader: Verbindung mit dem Server (%s) hergestellt\n", inet_ntoa (address.sin_addr));
} else {
printf("PacketReader: Could not connect to Server 127.0.0.1 on port 2501!\n");
return 0;
}
while(1) {
printf("At beginning of while loop ...\n");
size = recv(create_socket, buffer, BUF-1, 0);
printf("Got after recv ...\n");
if( size > 0) buffer[size] = '\0';
printf("Got Message: %s\n", buffer);
}
close (create_socket);
return 0;
[...]
It appears as if the first recv worked fine but the second crashes the application ...
(This Code runs as a pthread.) Output is the following:
root@OpenWrt:/# /usr/local/bin/wispy
PacketReader: Socket wurde angelegt
Accepted interface connection from 127.0.0.1
PacketReader: Verbindung mit dem Server (127.0.0.1) hergestellt
At beginning of while loop ...
Got after recv ...
Got Message: *KISMET: 0.0.0 946685577 .Kismet. 20050815211952 1 2006.04.R1
*PROTOCOLS: KISMET,ERROR,ACK,PROTOCOLS,CAPABILITY,TERMINATE,TIME,ALERT,NETWORK,CLIENT,GPS,INFO,REMOVE,STATUS,PACKET,STRING,WEPKEY,CARD
At beginning of while loop ...
root@OpenWrt:/#
Any hints / tips?
Thank you ...
Robert