I'm simulating a client/server environment
Here is the error "can't open ethernet device"
It is supposed to be the simpliest. How come it doesn't work?
#define ETHERNET_DEVICE "/dev/eth0"
void main()
{
// char *str = "hello LAN\n";
char *str;
char *filenametosave = "/root/hello.txt";
FILE *filetosave;
FILE *fp;
int bytes_read = 0;
fp = fopen (ETHERNET_DEVICE, "r");
if (fp == NULL)
{
fprintf (stderr, "can't open ethernet device\n");
exit (-1);
}
filetosave = fopen (filenametosave, "w");
if (filetosave == NULL)
{
fclose (fp);
fprintf (stderr, "can't open database\n");
exit(-1);
}
str = (char *)malloc (10000);
for (;bytes_read == 0

{
bytes_read = fread (str, 10000, 1, fp);
printf ("Waiting for data...\n");
usleep(10000);
}
fwrite (str,1, strlen(str), filetosave);
fclose (fp);
fclose (filetosave);
}
Thanks
Jack