Reputation: 31
Is it possible that one application uses the same Ip @ and connects to three different applications using different protocols TCP and UDP?
Best regards,
Upvotes: 1
Views: 5034
Reputation: 12698
Port spaces are different for TCP and UDP, as they are different protocols. Nothing (but the range of values, that goes in both from 1 to 65535) makes them interchangeable. But many services that interoperate in both TCP & UDP select the same port number (if available, look in IANA for assigned numbers) to the same service. Anyway, being TCP a connection oriented, reliable protocol, without frame delimitation and UDP unreliable, packet delimited protocol, it is no much sense to use udp for some protocol if it is only specified for TCP media, or the reverse.
Both TCP & UDP can listen for packets in any (or all) of the interfaces of the host, so in order to allow several different UDP/TCP services to run in each interface, the protocols were specified with a port multiplexing/demultiplexing feature (the port numbers) This is what makes the kernel to decide to which socket to deliver the data comming from the network (demultiplexing) and what allows all packets (multiplexing) to share the same medium (the network wire)
Upvotes: 1
Reputation: 22966
Yes, one application can have several network connections using different ports and protocols all being on the same IP address.
Just open several sockets with their specific options.
The 'tricky' thing is going to be making sure that all sockets are read from and written to. You may need threads.
Upvotes: 1