By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

difference between socktype ad protocol?

P: n/a
hallo,
I'd like to understand the difference between socktype ad protocol:

in getaddrinfo or in cration of socket we have two arguments:
socketype and protocol:
ai_socktype: can have SOCK_STREAM, SOCKDGRAM, SOCKRAW
ai_protocol: 0 or IPPROTO_xxx (es. IPPROTO_TCP , IPPROTO_UDP)

SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?

what is the difference between socktype ad protocol?
thank you in advance,
Mario.
Jun 3 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Sun, 03 Jun 2007 22:35:14 +0200, in comp.lang.c , "_mario.lat"
<no**@libero.itwrote:
>hallo,
I'd like to understand the difference between socktype ad protocol:

in getaddrinfo or in cration of socket we have two arguments:
socketype and protocol:
ai_socktype: can have SOCK_STREAM, SOCKDGRAM, SOCKRAW
ai_protocol: 0 or IPPROTO_xxx (es. IPPROTO_TCP , IPPROTO_UDP)

SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?

what is the difference between socktype ad protocol?
thank you in advance,
This isn't really a C question - you will probably get a good answer
in comp.unix.programmer though, where networking is more topical.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 3 '07 #2

P: n/a
In article <pa****************************@libero.it>,
_mario.lat <no**@libero.itwrote:
>I'd like to understand the difference between socktype ad protocol:
>SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?
>what is the difference between socktype ad protocol?
That's a networking question rather than a C question; like the
other poster said, the unix newsgroup would be a better place for
the details.

[OT]
The approximate answer is that SOCK_STREAM is a class that includes
*any* kind of reliable transport, and SOCKDGRAM is a class that
includes *any* kind of transport that handles individual unreliable
messages.

For example, there are "improved" TCP-like protocols that work better
under particular conditions (e.g., some are optimized for high
bandwidth and low latency such as LAN links; some are optimized for
high error loss and high latency such as talking to spacecraft.)
These protocols are not TCP nor UDP, so they are neither IPPROTO_TCP
nor IPPROTO_UDP, but they are still SOCK_STREAM or SOCK_UDP.
--
Programming is what happens while you're busy making other plans.
Jun 3 '07 #3

P: n/a
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.cawrote in message
news:f3**********@canopus.cc.umanitoba.ca...
In article <pa****************************@libero.it>,
_mario.lat <no**@libero.itwrote:
>>I'd like to understand the difference between socktype ad protocol:
>>SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?
>>what is the difference between socktype ad protocol?

That's a networking question rather than a C question; like the
other poster said, the unix newsgroup would be a better place for
the details.

[OT]
The approximate answer is that SOCK_STREAM is a class that includes
*any* kind of reliable transport, and SOCKDGRAM is a class that
includes *any* kind of transport that handles individual unreliable
messages.

For example, there are "improved" TCP-like protocols that work better
under particular conditions (e.g., some are optimized for high
bandwidth and low latency such as LAN links; some are optimized for
high error loss and high latency such as talking to spacecraft.)
These protocols are not TCP nor UDP, so they are neither IPPROTO_TCP
nor IPPROTO_UDP, but they are still SOCK_STREAM or SOCK_UDP.
<OT>
The above is not wrong, but originally sockets were intended to be used with
a variety of protocols, not just IP. DECnet, XNS, IPX, AppleTalk, OSI,
VINES, etc. have various sub-protocols similar to TCP and/or UDP which would
fit into the SOCK_STREAM, SOCK_DGRAM, or other types as well. A few were
actually even implemented on various systems, but they've fallen out of use
(obviously). At the time DARPA contracted BBN to implement what came to be
known as "BSD sockets", though, nobody had any clue IP would eventually
obliterate all other networking protocols and so they created one
complicated syscall that could potentially handle all protocols instead of
needing a separate syscall for each protocol.
</OT>
--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Jun 3 '07 #4

P: n/a
"Stephen Sprunk" <st*****@sprunk.orgwrites:
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.cawrote in message
news:f3**********@canopus.cc.umanitoba.ca...
>In article <pa****************************@libero.it>,
_mario.lat <no**@libero.itwrote:
>>>I'd like to understand the difference between socktype ad protocol:
>>>SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?
>>>what is the difference between socktype ad protocol?

That's a networking question rather than a C question; like the
other poster said, the unix newsgroup would be a better place for
the details.

[OT]
The approximate answer is that
[...]
>
<OT>
The above is not wrong, but originally
[...]

In my opinion, this illustrates why attempting to provide off-topic
answers, even if they're marked as such, is a bad idea. The above
discussion should have taken place in comp.unix.programmer.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 3 '07 #5

P: n/a

"Stephen Sprunk" <st*****@sprunk.orgwrote in message
news:46***********************@free.teranews.com.. .
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.cawrote in message
news:f3**********@canopus.cc.umanitoba.ca...
>In article <pa****************************@libero.it>,
_mario.lat <no**@libero.itwrote:
>>>I'd like to understand the difference between socktype ad protocol:
>>>SOCK_STREAM is not the same as TCP and SOCKDGRAM is not the same of
IPPROTO_UDP?
>>>what is the difference between socktype ad protocol?

That's a networking question rather than a C question; like the
other poster said, the unix newsgroup would be a better place for
the details.

[OT]
The approximate answer is that SOCK_STREAM is a class that includes
*any* kind of reliable transport, and SOCKDGRAM is a class that
includes *any* kind of transport that handles individual unreliable
messages.

For example, there are "improved" TCP-like protocols that work better
under particular conditions (e.g., some are optimized for high
bandwidth and low latency such as LAN links; some are optimized for
high error loss and high latency such as talking to spacecraft.)
These protocols are not TCP nor UDP, so they are neither IPPROTO_TCP
nor IPPROTO_UDP, but they are still SOCK_STREAM or SOCK_UDP.

<OT>
The above is not wrong, but originally sockets were intended to be used
with a variety of protocols, not just IP. DECnet, XNS, IPX, AppleTalk,
OSI, VINES, etc. have various sub-protocols similar to TCP and/or UDP
which would fit into the SOCK_STREAM, SOCK_DGRAM, or other types as well.
A few were actually even implemented on various systems, but they've
fallen out of use (obviously). At the time DARPA contracted BBN to
implement what came to be known as "BSD sockets", though, nobody had any
clue IP would eventually obliterate all other networking protocols and so
they created one complicated syscall that could potentially handle all
protocols instead of needing a separate syscall for each protocol.
</OT>
<MORE OT>

Some of those protocols defined more than what DGRAM and STREAMS
convey. Often "level two" protocols are implied by some. I have personally
known of a broken implementation of TCP/IP taking down an entire LAN
from a different vendor.

</MORE OT>
Jun 4 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.