i have a problem with my programm and i hope you can help me.
i have a client and a server. the server is in an infinite loop and reacts when the client is sending the following phrases:
LIST
GET
QUIT
ok, when the client is typing LIST the server reacts and gives out the list of the directory which the client typed in as an argument.
ok the client send LIST to the server. server recognized it and send the list of the directory back to the client. everything is fine.
when the client send QUIT he leaves the server.
ok now to my problem. when i typed in GET the server recognized it as well, BUT i can't send something back to the client. it did not reach the client. and i dont know why.
here the code, i hope you can help me. maybe its very easy, but i dont see the mistake:
elseif(strncmp(buffer, "GET",3) == 0)
{
printf ("Message received: %s\n", buffer);
from = fopen("test.txt", "r");
if(NULL == from)
{
//i tried sprintf and strcpy. doesnt matter
sprintf(buffer,"no such file - ERROR");
//send to client
send(new_socket, buffer, strlen(buffer),0);
}
else
{
sprintf(buffer,"file exists");
//send to client
send(new_socket, buffer, strlen(buffer),0);
}
}
client:
1 2 3 4 5 6 7
elseif(strcmp(buffer,"GET\n") == 0)
{
//GET command to the server
send(create_socket, buffer, strlen (buffer), 0);
//response from the server:
size=recv(create_socket,buffer,BUF-1, 0);
}
Usually, if me, I would first catch tcpdump at the server side to make sure whether the info in "buffer" has been sent out or not. By this way, first locate whether the problem is at server or client side.