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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -