SOCKET() on Linux and QNX

this line “socket(AF_INET, SOCK_STREAM, 0);” in Linux return 4(SOCK_RDM) and in QNX return 5(SOCK_SEQPACKET). why? and this return value 5 make the connect() failed. thanks.

huh? socket() returns an FD, nothing more. So on linux the first free FD is 4 and on QNX it is 5, there is nothing to interpret about it.

The return value of SOCKET() are the first argument of CONNECT(), if it is 4, the CONNECT() establish a SOCK_RDM type socket, while 5 is a SOCK_SEQPACKET type socket. this is from QNX user manul->library reference. so i think FD is not meaning “nothing more”.

BTW, i set the first argument of CONNECT() 4, the function will be OK.

You are very confused I think! :slight_smile:

The type of the socket is not encoded in the int returned from the call to socket(). It is set by the parms passed into socket() and you then pass the returned value from socket() into connect(). So if you aren’t creating the socket properly it won’t work.

You should try out this site, it is very informative:
ecst.csuchico.edu/~beej/guide/net/

The site is very helpful for me. thanks for help!

I already resolve the problem. It is due to argument mismatch.