windows - Comparing contents received at Socket with a String in UDP -


i have developed udp client server application. want check if client sends string "exit", server receives string, compares "exit" string , program exits. in case, server not able compare received string "exit" string. below coding:

client:

char exitbuffer[]="exit"; if (sendto(socketidentifier,exitbuffer,strlen(exitbuffer) , 0 , (struct sockaddr *) &connectedsocket, sizeof(connectedsocket)) == socket_error) {     exit(exit_failure); } 

server:

if ((recv_len = recvfrom(socketidentifier, receivebuffer, sizeof(receivebuffer), 0, (struct sockaddr *) &clientsocket, &clientsocketlength)) == socket_error) {     messagebox(null,      exit(exit_failure); }  // comparing contents of receive buffer if (receivebuffer == "exit") {     exit(0); } 

i tried memcmp , did :) comparison done on server side follows:

if(memcmp(receivebuffer,"exit",5) == 0) {     //receivebuffer eqaul "exit". } 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -