loading...

Discussion on: The spelling bug

Collapse
palle profile image
Palle

Recently programmed a simple server application in C which managed multiple connections using epoll. However, the program could not receive messages from a connected client. After many hours of inspecting what went wrong, I found the bug.

It was in the line while ((new_connection = accept(fd, &new_addr, &len) != -1)).
Can you spot it?

Collapse
foxtacles profile image
Christian Semmler

new_connection always becomes true or false, and the value you actually expect to be stored gets lost. You probably meant this:

while ((new_connection = accept(fd, &new_addr, &len)) != -1)

Nasty one :D