linux - C Send Socket without Defining Socket -
what line of code do
send(4, "test\n", 15, 0);
if there no socket defined in code?
it fails, ebadf
error (in errno
).
see manual page more possible error values.
note could succeed, if there code before sets socket hardcoded descriptor value of 4
(the first argument). see dup()
function 1 way of attempting that.
also note parent process doing setup, might not visible in source file silently assumed.
finally note undefined behavior due reading outside provided buffer (the string isn't 15 characters long). pretty suspect code.
Comments
Post a Comment