zoukankan      html  css  js  c++  java
  • Socket程序中的Error#10054错误

    近期使用winSock做的一个网络项目中,使用TCP+Socket连接编写的一个多线程的网络程序,功能是client负责不断地向server端发送数据,服务端负责接收数据。client是一个DLL,服务端程序是一个随机启动的NT Service服务程序。

    程序在夜间无人操作的执行过程中,client常常不定时地出现错误号为:10054错误,而server端并没有对应的提示。执行环境是win2000+sp4,这个问题出现得比較莫名其妙。

    查了MSDN上的10054错误号说明:WSAECONNRESET     (10054)  
       
      Connection   reset   by   peer.    
       
      A   existing   connection   was   forcibly   closed   by   the   remote   host.   This   normally   results   if   the   peer   application   on   the   remote   host   is   suddenly   stopped,   the   host   is   rebooted,   or   the   remote   host   used   a   "hard   close"   (see   setsockopt   for   more   information   on   the   SO_LINGER   option   on   the   remote   socket.)

     也就是说,一个连接被对方重设。一个建立的连接被远程主机强行关闭,若远程主机上的进程异常终止执行(因为内存冲突或硬件故障),或者针对套接字执行了一次强行关闭,便会产生10054错误。针对强行关闭的情况,可用SO_LINGER套接字选项和setsockopt来配置一个套接字。

  • 相关阅读:
    python yaml文件数据按原有的数据顺序dump
    HTMLTestRunner
    os.path获取当前路径及父路径
    update 字符串拼接
    VSCode 快速生成.vue基本模板、发送http请求模板
    Vue取消eslint语法限制
    node-sass安装失败解决方法
    docker 创建mysql和redis
    阿里云镜像加速器地址
    .net core + xunit 集成测试
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/3752556.html
Copyright © 2011-2022 走看看