断开服务器的TCP客户端 [英] disconnect a client from server TCP

查看:115
本文介绍了断开服务器的TCP客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我C编写。很多客户端的服务器/客户端的TCP应用程序可以在同一时间被连接到服务器。如何在客户端断开10秒后,他被称为close()方法?

I write a server/client TCP application in C .Many clients can be connected to the server at the same time. How can a client be disconnected after 10 seconds he called close()?

推荐答案

只需拨打停机时​​关闭所接受的套接字文件描述符,提供你所谈论的香草伯克利插座在某种类型的UNIX。

Just call shutdown and close on the accepted socket file descriptor, providing you're talking about vanilla Berkely sockets in a UNIX of some kind.

您将不得不出管理时间以任何方式适合您的应用程序的架构。你必须运行一个计时器的地方的,有没有办法自动获得O / S超时的活动连接。

You'll have to manage the time out in whatever way is appropriate to the architecture of your application. You'll have to run a timer somewhere, there is no way to automatically get the O/S to time out an active connection.

这篇关于断开服务器的TCP客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆