Address already in use的解决方法
当客户端保持着与服务器端的连接,这时服务器端断开,再开启服务器时会出现: Address already in usr。
可以用netstat -anp | more 可以看到客户端还保持着与服务器的连接(还在使用服务器bind的端口)。这是由于client没有执行close,连接还会等待client的FIN包一段时间。
解决方法是使用setsockopt,使得socket可以被重用,是最常用的服务器编程要点。
具体的做法为是,在socket调用和bind 调用之间加上一段对socket的设置:
int opt = ;
setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));
Address already in use的解决方法的更多相关文章
- Jenkins启动时报错:java.net.BindException: Address already in use: bind 解决方法
下载jenkins.war包后,进入Jenkins.war包目录下,运行java -jar jenkins.war时报端口被占用的错误:java.net.BindException: Address ...
- Centos7 开机显示 ERST: Failed to get Error Log Address Range” 导致无法开机解决方法
开机显示 ERST: Failed to get Error Log Address Range” 导致无法开机,也无法重新安装系统,解决方法:开机进入BIOS , 关闭ACPI选项即可正常开机
- ipv4、ipv6的socket同时监听“bind: Address already in use”的解决方法
创建ipv4和ipv6的socket,同时监听某个端口的ipv4和ipv6报文,运行时bind函数执行失败,提示“bind: Address already in use”.原因:ipv6的socke ...
- JMeter压测“java.net.BindException: Address already in use: connect”解决方法
之前在windows机上用JMeter压测,50并发下出现大量接口报“java.net.BindException: Address already in use: connect”错误. 从字面的意 ...
- wget: unable to resolve host address ‘dl.grafana.com’的解决方法
[root@Server-qnrsyp system]# wget --no-check-certificate https://dl.grafana.com/oss/release/grafana_ ...
- MyEclipse 启动 tomcate 失败 解决方法
MyEclipse中启动tomcate失败 十月 20, 2015 9:53:04 下午 org.apache.catalina.startup.VersionLoggerListener log信息 ...
- php连接memcahed出现Cannot assign requested address (99)的解决方法
今天在将服务器合并后,发现php偶尔会报出 Server *.*.*.* (tcp *****) failed with: Cannot assign requested address (99) 的 ...
- Error, some other host already uses address 192.168.0.202错误解决方法
Error, some other host already uses address 192.168.0.202错误解决方法 今天配置虚拟机网卡的时候遇到错误:Error, some other h ...
- The address where a.out.debug has been loaded is missing以及No symbol "*" in current context原因与解决方法
最近,在debug core的时候,发现p 变量的时候提示“No symbol "*" in current context”,我们的代码使用-g编译的,经查有可能是下列几个原因或 ...
随机推荐
- SQL 经典练习题
create database 练习题gouse 练习题go create table Student( Sno char(3) primary key, Sname char(8) not null ...
- Android 字体相关总结
1.Android系统默认支持三种字体,分别为:“sans”, “serif”, “monospace“ 系统缺省方式(经试验缺省采用采用sans): 2.在Android中可以引入其他字体 3. ...
- Golang Clearing slice
//first method : slice = nil // second method : slice = slice[0:0] Source page : https://www.socketl ...
- python数据结构与算法——栈
# 栈# 其实python里面的list就可以当栈使用啦,用collections.deque也可以# 1. 入栈 list.append(item)# 2. 出栈 item = list.pop() ...
- MVC的用法和作用
最近在学习IOS项目的时候,老师经常提起MVC,在理解的过程中,越来越发现MVC的魅力,MVC:M:Model V:View C:Controller:Model 是用来存储数据的,View 是用来显 ...
- 数论 UVA 11076
这道题目的意思简单易懂说的是给你n个数(可能有重复相同的数字),列出他们所有排列的情况,再逐位相加,求出和,例如:给你1,2,3,则排列的情况为<123>, <132>, &l ...
- java 压缩文件 传入文件数组,压缩文件,在指定路径下生成指定文件名的压缩文件
/** * 传入文件数组,压缩文件,在指定路径下生成指定文件名的压缩文件 * * @param files * 文件数组 * @param strZipName * 压缩文件路径及文件名 * @thr ...
- LeetCode【169. Majority Element】
Given an array of size n, find the majority element. The majority element is the element that appear ...
- Ant——ant的使用
---------------------------------------------------------------------------------------------------- ...
- SQL 数据库的使用
<1>存到数据库 CSql Sql; Sql.SqlSave(15, &m_SALink, 0, 0, 0, 0); <2>取数据 int *pt = new int[ ...