hi here is my some code for Linux i would like to convert it in Windows but i do not know what s that code do in Linux as i am not programmer for Linux OS. so please any body can describe what that samll piece do or what wil be the output. and PArticulery the daemon(0,0) whts does means by passing ZERO argument to this functions ?
Code:
#include<unistd.h>
..............................
..........................
void echoServerInit(void);
void echoClientInit(void);
int main(int argc, char **argv) {
int startEchoClient = 1;
int startEchoServer = 1;
int daemonize = 0;
int optc;
while ((optc = getopt(argc, argv, "scd")) > 0) {
switch (optc) {
case 's':
startEchoClient = 0;
startEchoServer = 1;
break;
case 'c':
startEchoClient = 1;
startEchoServer = 0;
break;
case 'd':
daemonize = 1;
break;
default:
printf("Invalid option %c\n", optc);
return(-1);
}
}
if (daemonize) {
if (daemon(0, 0) < 0) {
printf("Can't run as daemon: %s\n", strerror(errno));
return(-1);
}
printf("main: running as daemon, pid %d\n", getpid());
}
/* Start up service*/
dctpoInit();
/* Start up the echo server */
if (startEchoServer) {
printf( "main: starting echo-server\n");
echoServerInit();
}
/* Give it time to init */
sleep(3);
/* Start up the echo client */
if (startEchoClient) {
printf( "main: starting echo-client\n");
echoClientInit();
}
/* Let them do their things */
while (1) {
sleep(10);
}
return(0);
}
CHEERS!