Re: How can I Listen for TCP and UDP on a single port?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kelvin,

I'm no expert in socket programing, I might be wrong  ;)

Yes you can create and bind both TCP and UDP sockets to the same port.
Cos' TCP ports are independent of UDP ports. 

So you can just create a TCP socket; bind it and listen, follow by a UDP socket.

A very good reference will be Unix Network Programming: Sockets and XTI by Richard Stevens. Page 233   ;)  There is an example code on this. I think you can download the code on the net too.


Don



>>> "Kevin" <aotang@its.caltech.edu> 11/02/01 05:08PM >>>
Hi,
    I want to listen the TCP connection and UDP connection on a single port.
And use the select() to dectect the connection.
    I have two questions:
1. How can I build a socket for listening both of the two types of
connection?
2. How can get to know it is a TCP connection or a UDP connection?


-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org 
More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux