用C ++监控多个端口的服务器程序 [英] Server program in C++ to listen multiple ports

查看:76
本文介绍了用C ++监控多个端口的服务器程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好......

我正在尝试创建一个程序,服务器可以监听一个端口,并且在某些事件发生时它将停止侦听该端口并开始侦听其他端口并在收听其他端口之后它应该恢复以前的端口。

请帮我这个。



我尝试了什么:



我知道一种方法是使用线程但是如何?

Hello...
I am trying to create a program where server can listen to one port and on some event occurrence it will stop listening that port and start listening other port and after listening the other port it should resume the previous port.
Please help me with this.

What I have tried:

I know one way to do is using thread but how??

推荐答案

当然线程是解。您必须编写一些可以侦听不同端口的函数,并将它们作为不同的线程启动。



您是否考虑过搜索一些线程教程或好的视频教程
Ofcourse threading is the solution. You must write some functions which can listen to different port and start them as different thread.

Did you already think about searching some tutorial on threads or a good video tutorial?


这篇关于用C ++监控多个端口的服务器程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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