Tcp套接字编程C,C ++ [英] Tcp socket programming C, C++

查看:135
本文介绍了Tcp套接字编程C,C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有15个子系统数据要使用tcp协议从服务器发送/接收到辅助服务器。可用的端口号在服务器中受限,因此我创建了15个套接字,在同一端口上发送/接收15个子系统数据。无法为每个子系统创建线程,因为服务器中的进程数量也有限制。

问题是没有收到子系统数据,发送/读取错误。建议如何克服这个。



我尝试了什么:



i am using select( )发送/接收数据

I have 15 subsystems data to be send/receive from server to an auxiliary server using tcp protocol.The port number available is limited in server hence i had created 15 sockets, to send/receive 15 subsystem data on same port.I cannot create thread for each subsystem as there is also limitation of number of process in the server.
The problem is that randomly the subsystem data is not received,send/read error occurs.Kindly suggest how to overcome this.

What I have tried:

i am using select() for sending/receiving data

推荐答案

在进程内创建其他线程不会增加进程数。如果存在进程限制且没有(或更高)线程限制,则可以使用此选项。但是不要使用分叉因为这将创建新的进程。



克服此类错误的唯一建议是找到发送/读取错误的来源。这可以通过调试代码和/或检查代码是否存在可能的缺陷来完成。第一个只能由你完成,第二个需要显示代码(这可能太多了,不能在这里发布)。



如果你决定更新你的问题使用某些代码,您应该指出错误发生的位置以及返回的错误代码。
Creating additional threads inside a process does not increase the number of processes. If there is a process limit and no (or a much higher) thread limit, you can use this option. But don't use forking because that will create new processes.

The only suggestion to overcome such errors is finding the source of the send/read errors. This can be done by debugging your code and/or inspecting it for possible flaws. The first can be only done by you and the second requires showing the code (which might be too much to be posted here).

If you decide to update your question with some code you should indicate where the errors occur and which error codes are returned.


这篇关于Tcp套接字编程C,C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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