`

How to release the port of TCP Client immediately when the connection is disconnect with the TCP server. - TCP 客户端与 TCP 服务器断开连接后

 
阅读更多

How to release the port of TCP Client immediately when the connection is disconnect with the TCP server. - TCP 客户端与 TCP 服务器断开连接后,如何立刻释放端口

在 TCP C/S 模式下,当 TCP 客户端想断开的时候,不能用 shutdown 和 closesocket 与 TCP 服务器断开,只有让 TCP 服务器端主动断开(TCP 客户端被动断开),TCP 客户端的端口才能立刻被释放。

举个例子:

如果 TCP Client 要想与 TCP Server 断开 TCP 连接,TCP Client 可以向 TCP Server 发一个 “Quit” 字符串命令,

TCP Server 检测到 TCP Client 发送了 “Quit” 字符串,就 closesocket

TCP Client 侧的 socket 也会触发断开,这样 TCP Client 端口就可以立刻被释放

分享到:
评论

相关推荐

    Sakemail

    Fixed a minor bug with the boundary.- Change the generator of the message id.- Added the field MessageId and InReplyTo to the TSakMsg component.- Added the field In-Reply-To that is added to the ...

    Unity 网络 之 Networking 实现简单的网络服务器和客户端通讯功能封装(可监听多个客户端).rar

    1、NetworkServer 构建相关服务器的封装类,例如 服务器监听 NetworkServer.Listen(),断开服务器所有连接NetworkServer.DisconnectAll(),关闭服务器NetworkServer.Shutdown(),服务器发送数据给所有客户端Network...

    WPTools.v6.29.1.Pro

    + inside of the OnPrepareImageForSaving event it is now possible to set Writer.CurrentImageName to the name of the file which should be saved. This is only useful if ObjRef = nil and so no ObjRef....

    Albert-László Barabási的2018年新书《The Formula:the universal laws of success》

    "This is not just an important but an imperative project: to approach the problem of randomness and success using the state of the art scientific arsenal we have. Barabasi is the person." --Nassim ...

    socket.io-request:socket.io的双向请求-响应

    客户端到服务器的请求 客户 var ioreq = require ( "socket.io-request" ) ; var io = require ( "socket.io-client" ) ( "http://localhost:3000" ) ; io . on ( "connect" , function ( ) { ioreq ( io ) . req

    SignalR Programming in Microsoft ASP.NET

    Learn how SignalR uses Websockets when supported by the browser and the server and falls back to other techniques and technologies when it is not Use the simple ASP.NET API in SignalR for creating ...

    WINCE WIFI 工具 wzctool.exe

    connect to AP-SSID with given parameters.", Use -c -? for detail. -reset Reset WZC configuration data. Wireless card will disconnect if it was connected. -set <Card Name> <parameter> Set WZC ...

    JLink_Windows_V648.zip

    DLL: When using J-Trace PRO with IAR EWARM a "failed to allocate x bytes of memory" error could occur. Fixed. DLL: Windows: Renesas RX: When using FINE interface and disabling ongoining debug mode on ...

    vb写的ole 回调函数

    'This sample demostrates the use of an ole object ptr being passed to 'an external (and optionally remote) ole server. The ole server then 'periodically calls a method on this object ptr. This has the...

    Bochs - The cross platform IA-32 (x86) emulator

    - Fix BIOS INT13 function 08 when the number of cylinders on the disk = 1 - I/O Devices - USB HP DeskJet 920C printer device emulation (Ben Lunt) - Misc - Updated Bochs TESTFORM to version 0.5 -...

    win3.x 下的wing 玩某些老游戏必备比如孔明传

    the bin directory of the SDK and send the generated report to wingbug@microsoft.com. Updated information on WinG is available on CompuServe in the WINMM forum and on ftp.microsoft.com. Known Bugs ...

    华为H3C认证客户端 For linux

    说明:Linux系统下的H3C 802.1x兼容客户端,本程序需要lippcap支持 用法: usage: ./h3cclient [-d] [-r] [-h] [-k] -u username/password interface -d --daemon run as daemon. -r --renew renew IP address...

    Citrix_XenApp5

    • The LHC is a partial copy of the datastore database that every XenApp server maintains locally to the server itself  Continue running based on the configuration that is last received from the ...

    Gobi3000代码 高通

    Cleanup correctly during Disconnect() to fix possible race condition which could cause future connections to have read timeouts. Prior Release (Gobi3000 API 2012-01-09-0906) a. Fix memory leak in ...

    S7-200 SMART ISO-on-TCP 通讯.pptx

    S7-200 SMART ISO-on-TCP 通讯;ISO-on-TCP 通讯概述;通信项目:ISO-on-TCP通讯;(1)测试设备搭建 ...用户可通过DISCONNECT指令断开通讯连接。如图9所示:;图10. DISCONNECT指令;图11.库存储器;(3)S7

    TICQClient Version

    to Nick Anikin)[-] Fixed OnConnectionRefused event, it wasn‘t called when connection with ICQ server was lost (Thx! to Mironov Serghei)[-] Application containing TTimer on the same form as ...

    VB编程资源大全(英文源码 网络)

    You can send messages with a client/server type setup.<END><br>57 , al40.zip Apparently, if you use AOL to connect to the Internet and you do not touch it for 45 minutes it will timeout and drop ...

    TCP-IP详解卷3:TCP事务协议

    1.3 TCP上的客户-服务器 6 1.4 T/TCP上的客户-服务器 12 1.5 测试网络 15 1.6 时间测量程序 15 1.7 应用 17 1.8 历史 19 1.9 实现 20 1.10 小结 21 第2章 T/TCP协议 23 2.1 概述 23 2.2 T/TCP中的新TCP选项 23 2.3 T...

    system mechanic Activator v1.0

    * Disconnect internet during installation, and/or make sure to BLOCK the prog from connecting to internet (block unwanted traffic by using e.g. a firewall). 01. Install System Mechanic 10 as a ...

    移动主叫流程

    7.3.2 MSC 未下发Assignment request 而是直接下发Disconnect 拆除呼叫.................. 7-8 7.3.3 指配异常流程................................................................................................

Global site tag (gtag.js) - Google Analytics