网络知识

制式

美国有4种格式手机卡,网络和频率分别如下:
gsm:(800)/1900
tdma:(800)/1900
cdma:(800)/1900
(amps:800)

我国 GSM  通信系统采用 900MHz 和 1800MHz 频段。WCDMA 2100MHz

RF前端

socket编程

关于关闭socket之后出现address already in use

SO_REUSEADDR | SO_REUSEPORT

I've run into that same issue as well. It's because you're closing your connection to the socket, but not the socket itself. The socket can enter a TIME_WAIT state (to ensure all data has been transmitted, TCP guarantees delivery if possible)

一定要close(fd),要不然即使pthread_cancel之后,没有 close(fd),还是会出现address already in use.

Bind: Address Already in Use Or How to Avoid this Error when Closing TCP Connections

http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

setsockopt及keepalive

SO_BINDTODEVICE
Bind this socket to a symbolic device name like eth0 instead of using bind() to bind it to an IP address. Type the command ifconfig under Unix to see the device names.

SO_REUSEADDR
Allows other sockets to bind() to this port, unless there is an active listening socket bound to the port already. This enables you to get around those "Address already in use" error messages when you try to restart your server after a crash.

http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/

  # cat /proc/sys/net/ipv4/tcp_keepalive_time
  7200(s)
  # cat /proc/sys/net/ipv4/tcp_keepalive_intvl
  75(s)
  # cat /proc/sys/net/ipv4/tcp_keepalive_probes
  9次

修改为:

# echo 600 > /proc/sys/net/ipv4/tcp_keepalive_time
# echo 60 > /proc/sys/net/ipv4/tcp_keepalive_intvl
# echo 20 > /proc/sys/net/ipv4/tcp_keepalive_probes

sudo nano /etc/sysctl.conf:

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值