从单个客户端接口C连接到多台服务器 [英] Connecting to multiple servers from a single client socket C

查看:86
本文介绍了从单个客户端接口C连接到多台服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个尝试连接到使用插座S1我的主服务器的单个客户端。客户端需要不断尝试与S​​1连接到主服务器,但在同一时间连接,并不断发出努力的消息我的备用服务器。它是建立2个插槽,端口复用,并为那些2个插槽创建2个绑定或有更好的方法来实现这一目标是一个好主意?这是一个客户端和用C套接字。谢谢你。

I have a single client that is trying to connect to my main server using socket s1. The client needs to keep trying to connect to main server with s1, but at the same time connect and keep sending "trying" messages to my secondary server. Is it a good idea to create 2 sockets,reuse port and create 2 binds for those 2 sockets or there are better ways to achieve this? This is a client side and using C sockets. Thanks.

推荐答案

如果你的程序是一个客户端对多个服务器,使用每个服务器一个插座。你不需要绑定的客户端套接字所有,只是连接

If your program is a client to multiple servers, use one socket per server. You don't need bind for a client socket at all, just connect.

这篇关于从单个客户端接口C连接到多台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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