Problem
I am trying to run the Sample client program taken from the SCO Development System Network Programmer's Guide and Reference, Chapter 7, Example 7-12.
When I compile the code, I get this error message:
"client.c", line 33: error: prototype mismatch: 4 args passed, 3 expected
Solution
Using your favorite editor, search for the line:
if (connect(s, (struct sockaddr*)&sin, sizeof(sin), 0) == -1) {
The connect function only takes three parameters; however, the
documentation has an extra parameter, which is the '0'. The zero
can be taken out. The line should then look like this:if (connect(s, (struct sockaddr*)&sin, sizeof(sin)) == -1) {NOTE: There is something else wrong with this code that does not give
the desired output. The output always reads:tom: connect: Connection refusedTo correct this, search for the line:
sin.sin_port = PORTNUM;This line is missing the htons(SLIB) routine, which converts 16 and 32-bit quantities between network byte order and host byte order.
Change it to:sin.sin_port = htons(PORTNUM);This problem has been reported to SCO Engineering.
See also
byteorder(SLIB), gethostbyname(SLIB), getservent(SLIB)