tags:

views:

113

answers:

2

I've just answered problem with sockets in c# where in my example code I initializing my socket using ProtocolType.IP as this is what I've always used in my own code, and it has never caused me problems. But I see many examples specifying ProtocolType.Tcp.

I guess, what I'm asking is, by using ProtocolType.IP instead of ProtocolType.Tcp is anything being performed differently under the hood that I should be aware of?

A: 

check this link: http://www.allinterview.com/showanswers/1447.html

TCP/IP is a protocol suite, means it is the combination of protocols which are related to TCP and IP. TCP is a transport layer protocol whereas IP is a network layer protocol. TCP is a connection oriented protocol and IP is a connection less protocol

Hope it helps

cornerback84
+1  A: 

I would guess that ProtocolType.IP opens a "raw IP" socket, in other words it just squirts raw bytes onto the network as IP packets rather than going through the TCP or UDP protocol layers.

In contrast to TCP, you won't get guaranteed delivery of packets, packets may arrive out of order and/or packets may be duplicated. TCP handles all this as part of its protocol.

For almost all purposes I would expect you should be using ProtocolType.Tcp or ProtocolType.Udp unless you are doing some low-level networking stuff writing your own transport protocol.

Paolo
In fact that is the case, if I hadn't been using stream as my socket type. IP and Stream will always be TCP/IP as stream sockets requires TCP. At least according to my understanding of the WinSock2 documentation. However if I had used something else other than stream behaviour would of been different or it would of fallen over due to a bad combination.
Sekhat