在bind邦定时,通常会出现bind:Address alreasy is use错误。

此错误可以用setsockopt函数避免

int setsockopt(int sockfd,int level,int optname,const void *optval,socklen_t optlen)

sockfd:套接字描述符

level:层次  SOL_SOCKET

optname:需要设置的选项

optval:指向存放选项值缓冲区的指针

optlen:optval缓冲区的长度

此函数放在bind函数之前

例如:

 /*使用套接字选项,避免出错*/
if(setsockopt(listenfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)) != )
{
perror("setsockopt");
exit();
}

bind:Address alreasy is use的更多相关文章

  1. 解决bind错误 bind: Address already in use

    关于bind错误的处理: bind: Address already in use 原因: 操作系统没有立即释放端口 解决一: 等待一段时间运行网络程序即可 解决二:通过setsockopt进行设置, ...

  2. bind: address already in use

    2016/04/18 09:46:06 server.go:36: listen at 0.0.0.0:9530 2016/04/18 09:46:06 server.go:39: listen er ...

  3. ipv4、ipv6的socket同时监听“bind: Address already in use”的解决方法

    创建ipv4和ipv6的socket,同时监听某个端口的ipv4和ipv6报文,运行时bind函数执行失败,提示“bind: Address already in use”.原因:ipv6的socke ...

  4. 报错处理——# Creating Server TCP listening socket *:6379: bind: Address already in use

    在启动redis时报错 # Creating Server TCP listening socket *:6379: bind: Address already in use 错误原因 6379地址已 ...

  5. 开启redis-server提示 # Creating Server TCP listening socket *:6379: bind: Address already in use--解决方法

    在bin目录中开启Redis服务器,完整提示如下: 3496:C 25 Apr 00:56:48.717 # Warning: no config file specified, using the  ...

  6. 解析:SO_REUSEADDR bind: address in use

    http://blog.sina.com.cn/s/blog_53a2ecbf010095db.html socket中的SO_REUSEADDR Q: 我正在写一个unix server程序,不是d ...

  7. probably another instance of uWSGI is running on the same address (127.0.0.1:9090). bind(): Address already in use

    probably another instance of uWSGI is running on the same address (127.0.0.1:9090). bind(): Address ...

  8. 阿里云:uwsgi--配置出错 bind(): Address already in use [core/socket.c line 769]

    按照网上配置nginx+uwsgi+django的文章,nginx启动成功,django启动也成功,单独用uwsgi --http :8000 命令启动uwsgi也成功.使用uwsgi  --sock ...

  9. probably another instance of uWSGI is running on the same address (127.0.0.1:9090). bind(): Address ...

    probably another instance of uWSGI is running on the same address (127.0.0.1:9090). bind(): Address ...

随机推荐

  1. Linux下异常信号

    我们介绍一些标准信号的名称以及它们代表的事件.每一个信号名称是一个代表正整数的宏,但是你不要试图去推测宏代表的具体数值,而是直接使用名称.这是因为这个数值会随不同的系统或同样系统的不同版本而不同,但是 ...

  2. Android远程服务

    一.远程服务主要代码 1.IService.aidl package com.shz.remoteservice; interface IService { String getTicketInfoB ...

  3. CoolCTO - 创业者的技术合伙人

    CoolCTO - 创业者的技术合伙人

  4. 【TFS 2017 CI/CD系列 - 02】-- Build篇

    .创建Build 登录TFS,在现有的[Projects]中选择一个需要要创建Build的Project,点击[Build & Release]跳转页面 在新页面中选择[Builds]选项卡, ...

  5. Node.js开发Web后台服务(转载)

    原文:http://www.cnblogs.com/best/p/6204116.html 目录 一.简介 二.搭建Node.js开发环境 2.1.安装Node.js 2.2.安装IDE开发Node. ...

  6. 解决Win7 64bit + VS2013 使用opencv时出现提“应用程序无法正常启动(0xc000007b)”错误

    应用程序无法正常启动(0xc000007b) 记得以前也遇到过这样的问题:网上的解决方法就是修复什么 今天配置opencv2.4.8+vs2013的时候,发现用老版本的程序是不是都会出现这样的现象啊! ...

  7. MySQL 资源大全

    干货!MySQL 资源大全 提交 我的留言 加载中 已留言 shlomi-noach 发起维护的 MySQL 资源列表,内容覆盖:分析工具.备份.性能测试.配置.部署.GUI 等. 伯乐在线已在 Gi ...

  8. Deepin-安装git

    sudo apt-get install git 命令介绍(安装软件):apt-get install 命令介绍(Debian系列以管理员运行的前缀):sudo

  9. libevent多线程使用事项

    转 http://www.cnblogs.com/Seapeak/archive/2010/04/08/1707807.html 在linux平台上使用c开发网络程序的同志们一般情况下都对鼎鼎大名的l ...

  10. MySQL基础笔记(六) 存储过程与函数

    写在开头:本文所有的示例都是基于workers表,表中保存了某公司的员工姓名.性别.工资.年龄和居住城市,如下: +----+-----------+--------+--------+------+ ...