well i am trying to store it into a buffer, however I am finding troubles getting the buffer to work:
here's a sample of what I have going on now:
Code:
char msgBuf ="NULL";
while( (num = read(0,message,sizeof(message))) > 0){
if(strcmp(message, "exit\n") == 0){
printf("Exiting . . .\n");
/* Close this connection. */
pthread_join(root, &temp);
close(sock);
exit(0);
}
//printf("EOM CHECK WITH %s, %d \n", message, strcmp(message,"EOM\n"));
if(strcmp(message, "SEND\n") == 0){
printf("SEND DOES = 0\n");
if(send(sock,msgBuf,1024,0) < 0){
pdie("Writing on stream socket");
}
}else{
strcat(msgBuf,message);
printf("Sizeof msgBuf %d\n", sizeof(msgBuf));
//strcat(msgBuf, message);
printf("msgBuf:\n %s", msgBuf);
}
If "SEND" is not the first input then it never works, thus always "strcat" the string. And then random things seem to start showing up:
Sizeof msgBuf 5
msgBuf:
Nullhi there
what going on
do you smell anything
SEND
ou mell anything
I have no idea where "ou smell anything" is coming from