
Originally Posted by
Codeplug
Some concrete examples that other can play with and examine might help.
gg
Sure. I think I figured part of it out though. For the output I had to use putc(stdout) and then fflush(stdout)
Code:
/*
* Simple listener program for use with NetCat
*
*/
#include <stdlib.h>
#include <stdio.h>
void PutStr(char *str)
{
int i;
for(i=0; str[i]!='\0'; i++)
{
putc((int)str[i], stdout);
}
fflush(stdout);
}
int main(int ac, char **av)
{
int ch, Counter=1, PortNum=atoi(av[1]);
char str[80];
sprintf(str, "\n\n\tRunning .........\n\n");
PutStr(str);
do{
sprintf(str, "\t\tYes, I am listening on port %d. [%d]\n", PortNum,Counter++);
PutStr(str);
ch=getchar();
}while(ch!='q');
return 0;
}
it is called like: >listener 4545
it works the same on DOS or linux.
Now I need to figure out how to get single character input without the user having to press <Enter> after each keypress ...