DEV Community

The spelling bug

─ 502 l4p1n ─► on March 18, 2017

I've been coding in the web section for about five years now and I faced many bugs. From silly syntax errors to annoying logic errors, I dealt with...
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