linux - What does the parameter protocol stand for in socket() system call? -


http://linux.die.net/man/2/socket

the protocol specifies particular protocol used socket. single protocol exists support particular socket type within given protocol family, in case protocol can specified 0. however, possible many protocols may exist, in case particular protocol must specified in manner. protocol number use specific 'communication domain' in communication take place;

http://linux.die.net/man/5/protocols

the field descriptions are:

protocol native name protocol. example ip, tcp, or udp.

when specifying second parameter either sock dgram or sock stream why again need protocol parameter?

there or can many different datagram or stream protocols. typical default af_inet , af_inet6 domain(when pass 0) streaming protocol tcp, , datagram protocol udp.

another interesting protocol sctp, can operate in both datagram , stream mode, can create sctp socket in either of these ways:

socket(af_inet, sock_stream, ipproto_sctp); socket(af_inet, sock_dgram, ipproto_sctp); 

an udp-lite variant can created

socket(af_inet, sock_dgram, ipproto_udplite); 

note socket() general call, , can used create non-ip based sockets, e.g. bluetooth, infrared, canbus protocols might provide different protocols can use.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -