lvalue required as left operand of assignment

Hi everyone, I got above error in my program. My program is socket program. I am using ubuntu 11.10.

#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <cstdlib>
#include <iostream>
#include <stdio.h>

#define PORT 4547

/*int parseARGS(char **args, char *line)
{
int tmp = 0;
args[tmp] = strtok(line, ":" );
while ((args[++tmp] = strtok(NULL, ":" )) != NULL);
return tmp -1;
}*/

int main(int argc, char *argv[])
{
char *header[4096];
int listenSOCKET, connectSOCKET;
socklen_t clientADDRESSLENGTH;
struct sockaddr_in clientADDRESS, serverADDRESS;
char recvBUFF[4096];
char *filename, *filesize;
FILE *recvFILE;
int received = 0;
char tempstr[4096];

int count1=1, count2=1, percent;

listenSOCKET = socket(AF_INET, SOCK_STREAM, 0);
if (listenSOCKET <0)
{
printf("Cannot create socket\n");
close(listenSOCKET);
return 1;
}
PORT = atoi(argv[1]);
serverADDRESS.sin_family = AF_INET;
serverADDRESS.sin_addr.s_addr = INADDR_ANY;
serverADDRESS.sin_port = htons(PORT);

if (bind(listenSOCKET, (struct sockaddr *)&serverADDRESS, sizeof(serverADDRESS))<0)
{
printf("Cannot bind socket\n");
close(listenSOCKET);
return 1;
}

listen(listenSOCKET, 5);
clientADDRESSLENGTH = sizeof(clientADDRESS);
connectSOCKET = accept(listenSOCKET,(struct sockaddr *)&clientADDRESS, &clientADDRESSLENGTH);
if (connectSOCKET<0)
{
printf("Cannot accpet connection\n");
close(listenSOCKET);
return 1;
}
bzero(recvBUFF,4096);
while(1)
{
if(recv(connectSOCKET,recvBUFF,1,0) = 0)
printf("ERROR on receiving");
}
close(listenSOCKET);
return 0;
}


if anyone know how to solve it.pls kindly tell me. thanks.
if(recv(connectSOCKET,recvBUFF,1,0) = 0)

Should be

if(recv(connectSOCKET,recvBUFF,1,0) == 0)
Hi thanks for your answer. After I change "==", I still got that error at line 21 which means int listenSOCKET, connectSOCKET. How to solve that? thanks again :)
Put your code in code tags please so I can know which line you are referring to

They are the ones in the reply box that look like "<>"
hi the error is like that

server4.cpp: In function ‘int main(int, char**)’:
server4.cpp:41:21: error: lvalue required as left operand of assignment

I have solved error. I found the error. It is because of that line

PORT = atoi(argv[1]);

Thanks a lot :)
Topic archived. No new replies allowed.