Socket Creation (InterNetwork, Stream, Tcp) vs (InterNetwork, Stream, Ip)

D

dean.greg

What is the difference between the two method of creating a socket?


new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.IP);

It is my understanding that the third parameter in this scenario has
no effect, because...

AddressFamily.InterNetwork = IPv4
SocketType.Stream = TCP

Or am I mistaken?
 
P

Peter Duniho

What is the difference between the two method of creating a socket?

new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.IP);
[...]

Well...did you *try* it?

It's true that the only stream protocol supported on TCP/IP is TCP, and so
the third parameter in this case should be superfluous. But it's my
recollection (possibly incorrect, I admit) that at least in Winsock, you
need to provide meaningful values. If you tried, for example, to specify
a connectionless, datagram-based protocol when also specifying a streaming
socket type, the call to socket() would fail. I would guess the same
thing would be true for the Socket class in .NET.

Keep in mind that TCP/IP is not the only networking protocol out there.
In other types of networks it is not necessarily true that the address
family with the socket type uniquely determine the protocol. The Socket
class, like Winsock, is designed to accomodate a wide variety of networks,
and not just TCP/IP. So it stands to reason that even if something is
superfluous for TCP/IP, the Socket class would not necessarily allow you
to just specify any random value for the third parameter to the Socket()
constructor.

But really, that brings me back to the original question. Did you
actually *try* the second example line of code? If so, what did it do? I
would suggest that is your best answer right there.

Pete
 
A

Arkady Frenkel

That should be exception in .Net if incorrect parameter set instead tcp in
this case
Arkady

Peter Duniho said:
What is the difference between the two method of creating a socket?

new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.IP);
[...]

Well...did you *try* it?

It's true that the only stream protocol supported on TCP/IP is TCP, and so
the third parameter in this case should be superfluous. But it's my
recollection (possibly incorrect, I admit) that at least in Winsock, you
need to provide meaningful values. If you tried, for example, to specify
a connectionless, datagram-based protocol when also specifying a streaming
socket type, the call to socket() would fail. I would guess the same
thing would be true for the Socket class in .NET.

Keep in mind that TCP/IP is not the only networking protocol out there.
In other types of networks it is not necessarily true that the address
family with the socket type uniquely determine the protocol. The Socket
class, like Winsock, is designed to accomodate a wide variety of networks,
and not just TCP/IP. So it stands to reason that even if something is
superfluous for TCP/IP, the Socket class would not necessarily allow you
to just specify any random value for the third parameter to the Socket()
constructor.

But really, that brings me back to the original question. Did you
actually *try* the second example line of code? If so, what did it do? I
would suggest that is your best answer right there.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top