Reputation: 13
Code is at the bottom.
The send() command on line 207 works fine on it's own. However, when I add the send() command on line 218, the first one fails - giving the error, "Bad address". I've confirmed that the second send() command isn't actually executed.
I'm completely lost here...
Upvotes: 0
Views: 39
Reputation: 782105
It looks like you're creating undefined behavior by using BUFFER_SIZE
as the amount to send, since this isn't likely to be the lengths of the two strings. Adding the second send()
call may be changing the memory layout of the strings, which results in the error you're getting.
It should be:
send(newsock_fd, "No such command in history", sizeof "No such command in history", 0);
If you don't want to send the trailing null byte, subtract 1 from sizeof
.
Upvotes: 1