"Artem Kazakov" <[EMAIL PROTECTED]> writes:
> The problem is that at some point a socket() function is called. And
> it returns descriptor = 1, which is a standart ouput.

socket() will not return 1 unless you previously closed descriptor 1,
either directly with close(1) or indirectly with fclose(stdout).

You probably did something like this:

    if (sd = socket(AF_INET, SOCK_STREAM, 0) != -1) {
        /* foo */
    }

which assigns either 1 or 0 to sd depending on whether socket()
returned -1.  You need to parenthesize the assignment:

    if ((sd = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
        /* foo */
    }

You also need to check the return value from either bind() or
connect() (they should have failed and set errno to ENOTSOCK), and
enable compiler warnings (gcc should have warned you about the dodgy
assignment / comparison).

DES
-- 
Dag-Erling Smørgrav - [EMAIL PROTECTED]
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to