diff options
author | bloodstalker <thabogre@gmail.com> | 2017-03-05 14:19:21 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2017-03-05 14:19:21 +0000 |
commit | 8909daf1fab3a6b976b6ebbc0682febe67aeb9ab (patch) | |
tree | 23b1c5feb8f09c91ee589f633a55b72a58cae835 /daemon/mutatorclient.c | |
parent | general fixes (diff) | |
download | mutator-8909daf1fab3a6b976b6ebbc0682febe67aeb9ab.tar.gz mutator-8909daf1fab3a6b976b6ebbc0682febe67aeb9ab.zip |
now the server sends something when the client snds a bad command so the client wont hang.
Diffstat (limited to 'daemon/mutatorclient.c')
-rw-r--r-- | daemon/mutatorclient.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/daemon/mutatorclient.c b/daemon/mutatorclient.c index 5686783..b60c02d 100644 --- a/daemon/mutatorclient.c +++ b/daemon/mutatorclient.c @@ -19,6 +19,12 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/ /**********************************************************************************************************************/ +/*macros*/ +#define __DBG +#if 0 +#undef __DBG +#endif +/**********************************************************************************************************************/ /*inclusion directive*/ #include "mutatorclient.h" /*standard header libraries*/ @@ -34,6 +40,7 @@ int main(int argc, char *argv[]) struct sockaddr_in server; char message[1000]; char server_reply[2000]; + int recvlength; /*create socket*/ sock = socket(AF_INET, SOCK_STREAM, 0); @@ -87,15 +94,32 @@ int main(int argc, char *argv[]) sleep(1); fflush(stdin); +#if defined(__DBG) + puts("checkpoint 1"); +#endif + /*recieve a reply from the server*/ - if (recv(sock, server_reply, 2000, 0) < 0) + recvlength = recv(sock, server_reply, 2000, 0); + +#if defined(__DBG) + puts("checkpoint 2"); +#endif + + if (recvlength < 0) { puts("recv failed."); break; } + else if (recvlength == 0) + { + puts("server sent no output."); + } + else + { + puts("server reply: "); + puts(server_reply); + } - puts("server reply: "); - puts(server_reply); for (int i = 0; i < 2000; ++i) { |