[Windows] Socket Server Failed to bind, error 10048
Address already in use.
Typically, only one usage of each socket address (protocol/IP address/port) is permitted.
This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that wasn't closed properly, or one that is still in the process of closing.
For server applications that need to bind multiple sockets to the same port number, 例如client进程被taskkill,再次启动的情况,consider using setsockopt(SO_REUSEADDR).
Client applications usually need not call bind at all—connect chooses an unused port automatically. When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed. This could happen with a call to another function later, including connect, listen, WSAConnect, or WSAJoinLeaf.
BOOL bOptVal = TRUE;
int bOptLen = sizeof(BOOL);
iResult = setsockopt(ListenSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&bOptVal, bOptLen);
if (iResult == SOCKET_ERROR)
{
char m[];
snprintf(m, , "%s %d: setsockopt failed, port %d failed with error: %d",
__func__, __LINE__, port_number, WSAGetLastError());
printf("%s\n", m);
freeaddrinfo(result);
closesocket(ListenSocket);
WSACleanup();
return -;
}
https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-setsockopt
[Windows] Socket Server Failed to bind, error 10048的更多相关文章
- kafka.common.KafkaException: Socket server failed to bind to hdp1:9092: Cannot assign requested address.
ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.K ...
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...
- C语言写了一个socket server端,适合windows和linux,用GCC编译运行通过
////////////////////////////////////////////////////////////////////////////////* gcc -Wall -o s1 s1 ...
- navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法
原文:navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法 ...
- Spark2.2出现异常:ERROR SparkUI: Failed to bind SparkUI
详细错误信息如下: // :: INFO util.log: Logging initialized @5402ms // :: INFO server.Server: jetty-9.3.z-SNA ...
- nova instance出错:"message": "Proxy error: 502 Read from server failed
执行 $ nova resize instance1 时候出错: {, "details": " File \"/opt/stack/nova/nova/com ...
- windows上zend server安装 报The server encountered an internal error or misconfiguration and was unable to complete your request -解决方法 摘自网络
windows上zend server安装完成后报如下错误: Internal Server Error The server encountered an internal error or m ...
- Linux下Socket编程的端口问题( Bind error: Address already in use )
Linux下Socket编程的端口问题( Bind error: Address already in use ) 在进行linux网络编程时,每次修改了源代码并再次编译运行时,常遇到下面的地使用错误 ...
- [BAT]通过schtasks.exe远程调用windows 2008 server上的计划任务,提示ERROR : Access is denied
在windows 2008 server 上建了一个计划任务,想通过命令 schtasks /run /tn "IPADForAdvisor_QA_APITest" /s SZPC ...
随机推荐
- # H - H HDU - 2066 (多起点、多终点问题)
H - H HDU - 2066 (多源点.多汇点问题) 一个图上,有M条边,Z个出发点,Y个终止点.求一条最短路,其中起点是Z中的任意一点,终点是Y中任意一点. Input 输入数据有多组,输入直到 ...
- P1044 栈(递归、递推、卡特兰、打表)
P1044 栈 题目背景 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表. 栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈). 栈的重要 ...
- SpringBoot系列之学习教程汇总
对应SpringBoot系列博客专栏,例子代码,本博客不定时更新 一.配置篇 SpringBoot系列之@PropertySource读取yaml文件 >> source down ...
- RedHat7.4配置yum网络源
本次RedHat版本为:Red Hat Enterprise Linux Server release 7.4 (Maipo). 将RedHat7.4的yum源替换为免费的CentOS对应版本yum源 ...
- python3启动子进程之 os.fork()
python3启动子进程之 os.fork() 先了解python3 os.fork() 使用说明 在生物学家开始克隆研究之前,计算机科学家就拥有成功的克隆历史.他们克隆了进程,尽管他们没有将其称为 ...
- Google Adsense付款方式添加西联付款
本文已同步到专业技术网站 www.sufaith.com, 该网站专注于前后端开发技术与经验分享, 包含Web开发.Nodejs.Python.Linux.IT资讯等板块. Google Adsens ...
- 28.4 Calendar 日历
/* * Calendar:日历,提供了一些操作年月日时的方法 * 获取 * 修改 * 添加 */ public class CalendarDemo { public static void mai ...
- 会话技术(session/cookie)
session可保存int double bool array string object:cookie只能保存stringsession 可通过php.ini文件查看存放的位置:cookie不同浏览 ...
- String 对象-->replace() 方法
1.定义和用法 replace() 方法用于字符串替换 语法: string.replace(searchvalue,newvalue) 参数: searchvalue:被替换的字符串 newvalu ...
- HTTP协议经典面试题整理及答案详解
无论你是Java.PHP开发者,还是运维人员,只要从事互联网行业,面试时都可能被问到HTTP协议相关知识.历时多天的呕心沥血,为你总结了HTTP协议的经典面试题.由于涉及内容比较繁杂不方便记忆,建议收 ...