欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

linux网络通信代码实例

程序员文章站 2022-07-09 22:12:36
TCP transmit control protocol UDP usrer data protocol linux 中网络名称和ip地址的相对应,如/etc/hosts,但...

TCP transmit control protocol

UDP usrer data protocol

linux 中网络名称和ip地址的相对应,如/etc/hosts,但这种映射只是本地机的映射

127.0.0.1       localhost
127.0.1.1       ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

DNS 域名解析器,主机中记录的DNS地址,见于/etc/resolv.conf

 Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search localdomain

linux 中服务所占的端口,见于/etc/services

# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/port-numbers and other
# sources like https://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services .
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.

tcpmux      1/tcp               # TCP port service multiplexer
echo        7/tcp
echo        7/udp
discard     9/tcp       sink null
discard     9/udp       sink null
systat      11/tcp      users
daytime     13/tcp
daytime     13/udp
netstat     15/tcp
qotd        17/tcp      quote
msp     18/tcp              # message send protocol
msp     18/udp
chargen     19/tcp      ttytst source
chargen     19/udp      ttytst source
ftp-data    20/tcp
ftp     21/tcp
fsp     21/udp      fspd
ssh     22/tcp              # SSH Remote Login Protocol
ssh     22/udp
telnet      23/tcp
smtp        25/tcp      mail
time        37/tcp      timserver
time        37/udp      timserver
rlp     39/udp      resource    # resource location
nameserver  42/tcp      name        # IEN 116
whois       43/tcp      nicname
tacacs      49/tcp              # Login Host Protocol (TACACS)
tacacs      49/udp
re-mail-ck  50/tcp              # Remote Mail Checking Protocol
re-mail-ck  50/udp
domain      53/tcp              # Domain Name Server
domain      53/udp
mtp     57/tcp              # deprecated
tacacs-ds   65/tcp              # TACACS-Database Service
tacacs-ds   65/udp
bootps      67/tcp              # BOOTP server
bootps      67/udp
bootpc      68/tcp              # BOOTP client
bootpc      68/udp
tftp        69/udp
gopher      70/tcp              # Internet Gopher
gopher      70/udp
rje     77/tcp      netrjs
finger      79/tcp
http        80/tcp      www     # WorldWideWeb HTTP
http        80/udp              # HyperText Transfer Protocol