Udp package in Tcp socket

What if we send Udp package in Tcp socket? Did the package lost or not?I think the packet is lost Because of tcp required to first establish a connection first.

Upvotes: 0

Views: 175

Answers (1)

blafasel
blafasel

Reputation: 1121

It's simply impossible.

If some program sends a TCP package to an open socket it does not put a piece of data in some sink. It produces a TCP Package with the right characteristics and hands it over to the network stack of the OS.

If it produced an UDP package with some other characterstics and hands this over to the network stack a UDP package will be sent. The generated package has nothing to do with any coincidential TCP connections in any state.

Your questions seems to be inspired by the wrong imagination that opening a socket means something like building up a direct wire to the other endpoint and keeping my end of the wire to put some data into. This is not the case!

So there simply is no such end of a TCP socket where you can drop UDP packages in.

Upvotes: 1

Related Questions