如何在tcp / ip通信中接受来自任何IP地址的连接 [英] How to accept connections from any IP address in tcp /ip communication
本文介绍了如何在tcp / ip通信中接受来自任何IP地址的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了以下代码
server.sin_addr。 s_addr = inet_addr(10.170.0.42); 在我的程序中接受和接收图像,即仅在我的localhost中。
如何接受图像没有定义特定的IP,意味着我如何接受来自n个用户的图像。
可以有人给出语法
Hi,
I have used the following code
server.sin_addr.s_addr = inet_addr("10.170.0.42"); in my program to accept and receive images i.e in my localhost only.
how to accept the images without defining particular IP, means how can i accept images from n number of users.
can somebody give the syntax
推荐答案
语法是
serveraddr_A.sin_addr.s_addr = htonl(INADDR_ANY);
这是获取任何IP adre.ss的语法
The syntax is
serveraddr_A.sin_addr.s_addr=htonl(INADDR_ANY);
this is the syntax for getting any IP adre.ss
这篇关于如何在tcp / ip通信中接受来自任何IP地址的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文