bind: Invalid argument
出现此问题在于,listen函数在socket函数和bind函数之间。
例:
/*客户端程序开始建立sockfd描述符*/
listenfd = socket(AF_INET,SOCK_STREAM,);
if(listenfd < )
{
perror("socket");
exit();
}
/*使用套接字选项,避免出错*/
if(setsockopt(listenfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)) != )
{
perror("setsockopt");
exit();
}
/*服务器填充sockaddr结构*/
bzero(&server,sizeof(server)); //对结构体清零
server.sin_family = AF_INET; //IPv4地址族
server.sin_addr.s_addr = ntohl(INADDR_ANY); //服务器IP址址
server.sin_port = ntohs(); //端口号 /*设置允许连接的最大客户数*/
if(listen(listenfd,MAX_LISTEN_QUE) != )
{
perror("listen");
exit();
} /*邦定sockfd描述符到IP地址*/
int len = sizeof(struct sockaddr);
if(bind(listenfd,(struct sockaddr *)&server,len) != )
{
perror("bind");
exit();
}
如此操作时,容易出现bind: Invalid argument
bind: Invalid argument的更多相关文章
- file_put_contents 错误:failed to open stream: Invalid argument 一种原因
今天在测试nilcms系统的时候,出现了一个报错,导致缓存无法更新: file_put_contents(C:\UPUPW_AP5.4\vhosts\d.tv\NilCMS_APP\include_r ...
- fdisk添加分区引起的Linux Error: 22: Invalid argument
在Linux服务器(虚拟机)上使用fdisk添加分区.格式化分区后,遇到了Linux Error: 22: Invalid argument错误,操作步骤如下所示 [root@oracle-serve ...
- -bash: ulimit: pipe size: cannot modify limit: Invalid argument
从root账号切换到oracle账号时,出现了"-bash: ulimit: pipe size: cannot modify limit: Invalid argument"提示 ...
- 【安卓】aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creating directories: Invalid argument
这几天在使用.aidl文件的时候eclipse的控制台总是爆出如下提示: aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creatin ...
- php foreach 语法的遍历来源数组如果不是一个有效数组php会出现错误警告 Invalid argument supplied for foreach()
在php中,foreach语法的遍历来源数组如果不是一个有效数组,php会出现错误警告 Invalid argument supplied for foreach() ,但是很多时候这个数组是取自某些 ...
- Yii 提示Invalid argument supplied for foreach() 等错误
Yii 提示Invalid argument supplied for foreach() 或者 undefined variable: val等错误 只需要在对应的文件中加入error_report ...
- write函数出错返回invalid argument(EINVAL)问题
还是在下载机上面遇到的. 话说为了长久的下载,后面又买了个16G的U盘格成EXT3放在角落下载,结果发现总是有几个种子在下载的时候会出错提示invalid argument. 之前也出过一样的错误提示 ...
- PHP--Warning: Invalid argument supplied for foreach() in ...
1.背景 今天学习PHPExcel的使用,在代码执行foreach($data as $value){...}的时候出现这样一个警告提示:Warning: Invalid argument suppl ...
- iOS 开发之 Xcode6 installation failed invalid argument!
1.运行模拟器的时候 报出: installation failed invalid argument! 原因分析: 我把Bundle indentifier 置为空了! http://stackov ...
随机推荐
- Sublime3 Preference, Settings-User
{"font_face": "Consolas","font_size": 15,"ignored_packages": ...
- JAVA_the user operation is waiting怎么办
彻底解决 MyEclipse出现the user operation is waiting的问题 2011-05-31 10:32:30| 分类: 软件编程 | 标签:java myecli ...
- win7下装ubuntu双系统后无法进入win7的解决方法
本来电脑的系统是win7,然后用u盘装了ubuntu之后可能会出现开机没有引导界面而直接进入ubuntu系统的情况. 原因:没有设置gurb引导 解决方法:需要更新gurb来使ubuntu识别出win ...
- 图像处理之基础---boxfiter
http://blog.sina.com.cn/s/blog_7221228801019yg2.html DSP6000图像位移与变形典型算法 http://blog.csdn.net/anson20 ...
- 偶遇HiWork,请不要擦肩而过
非常多朋友可能都不了解HiWork,在这里介绍一下. HiWork是基于云存储的团队即时沟通协作平台,主要针对于中小团队及中小企业的即时沟通,让团队沟通更顺畅.在HiWork平台可即时得知所使用第三方 ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
E. Prairie Partition It can be shown that any positive integer x can be uniquely represented as x = ...
- su 和 su- 会影响环境变量
大部分Linux发行版的默认账户是普通用户,而更改系统文件或者执行某些命令,需要root身份才能进行,这就需要从当前用户切换到root用户,Linux中切换用户的命令是su或su -,下面就su命令和 ...
- Cg入门23: Fragment shader – UV动画(序列帧)
让动画从1-9循环播放此纹理 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkF ...
- Lightoj 1019 - Brush (V)
算出从点1到点n的最短路径. /* *********************************************** Author :guanjun Created Time :2016 ...
- JavaScript 实现的 SHA1 散列
1.代码:/**** Secure Hash Algorithm (SHA1)* http://www.webtoolkit.info/***/ function SHA1 (msg) { ...