完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
在上面的代码中,如果我删除TCPIpU-UppIbDUE(),代码会按预期的方式运行,并将数据发送到远程端口。但是,当我在本地绑定时,远程主机最初不接收任何数据。然而,当远程设备在端口LoalAlxPoT上向上述客户端发送数据时,客户端将数据发送到远程设备。为什么客户端设备在使用本地绑定时需要一个初始触发器?我在这里做错了什么?任何帮助将不胜感激!
以上来自于百度翻译 以下为原文 case APP_TCPIP_OPENING_CLIENT: { SYS_CMD_READY_TO_READ(); if (APP_Send_Packet) { APP_Send_Packet = false; IPV6_ADDR addr; TCPIP_Helper_StringToIPv6Address(APP_Hostname_Buffer, &addr); uint16_t port = atoi(APP_Port_Buffer); appData.clientSocket = TCPIP_UDP_ClientOpen(IP_ADDRESS_TYPE_IPV6, port, (IP_MULti_ADDRESS*) &addr); if (appData.clientSocket == INVALID_SOCKET) { SYS_CONSOLE_MESSAGE("Could not start connectionrn"); appData.clientState = APP_TCPIP_OPENING_CLIENT; } SYS_CONSOLE_MESSAGE("Starting connectionrn"); uint16_t local_port = 50728; if(!TCPIP_UDP_Bind(appData.clientSocket, IP_ADDRESS_TYPE_IPV6, local_port,0)) { SYS_CONSOLE_PRINT("Could not bind to local port %drn",local_port); } appData.clientState = APP_TCPIP_WAIT_FOR_CONNECTION; } } case APP_TCPIP_WAIT_FOR_CONNECTION: { if (!TCPIP_UDP_IsConnected(appData.clientSocket)) { break; } if(TCPIP_UDP_PutIsReady(appData.clientSocket) == 0) { break; } TCPIP_UDP_ArrayPut(appData.clientSocket, (uint8_t*)APP_Message_Buffer, strlen(APP_Message_Buffer)); TCPIP_UDP_Flush(appData.clientSocket); appData.clientState = APP_TCPIP_WAIT_FOR_RESPONSE; appData.mTimeOut = SYS_TMR_SystemCountGet() + 15*SYS_TMR_SystemCountFrequencyGet(); } break; In the above code, if I remove TCPIP_UDP_Bind(), the code functions as expected and sends out the data to the remote port. But, when I have the local bind in place, the remote host doesn't receive any data initially. However, when the remote device sends data to the above client on port local_port, then the client sends data to the remote device. Why does the client device require an initial trigger when I use local binding? What am I doing wrong here? Any help would be appreciated! |
|
相关推荐
6个回答
|
|
您所调用的绑定操作清除套接字的接口选择。当接口=0时,套接字将无法传输。使用ATCPIPUDUpSoCKETNETSET()来选择绑定后的正确接口,或者在绑定调用中提供适当的IPv6地址。另一方面,您真的需要特定的本地端口吗?也许你可以完全避免Band()。
以上来自于百度翻译 以下为原文 The bind operation that you call clears the interface selection for the socket. With an interface == 0, the socket won't be able to transmit. Use a TCPIP_UDP_SocketNetSet() to select the proper interface after your bind. Or provide a proper IPv6 address of the interface in the bind call. P.S. On the other hand, do you really need a specific local port? Maybe you can avoid the Bind() completely. |
|
|
|
你好,rainad,谢谢你的澄清。我可以在调用绑定中指定IPv6地址后得到它的工作。我确实需要一个特定的端口来为我的应用程序做广告,因为我在网络中的其他设备上发布我唯一的端口号,并且我的服务的所有事务都将在这个唯一的端口上运行。
以上来自于百度翻译 以下为原文 Hi rainad, Thank you for the clarification. I could get it working after specifying the IPv6 address in the call to bind. I do need a specific port for my application as I advertise my unique port number to the other devices in the network and all the transactions of my service would operate on this unique port. |
|
|
|
你能帮我解决另一个问题吗?HTTP://www. McCHIP.COM/FUMUSS/M9566ASPXIT一直阻止我用我的PoC进一步发展。
以上来自于百度翻译 以下为原文 Could you also help me with my other question? http://www.microchip.com/forums/m995566.aspx This has been blocking me from progressing further with my POC. |
|
|
|
我想你可以在打开插座后为你的本地端口做广告,这样就消除了绑定的要求。请看另一个帖子,我做了一些评论。
以上来自于百度翻译 以下为原文 I guess you can advertise your local port after you open the socket - and thus eliminate the call for Bind. Please see the other post, I made some comments. |
|
|
|
如果我不把客户端绑定到一个特定的本地端口,我相信堆栈会为每个事务分配一个短暂的端口。我将不得不在我的SRV记录中宣传我唯一的短暂端口(我应该使用我所有的事务),而在我之前通过MNS为我的服务做广告。启动事务。网络上的其他设备只在这个端口上向我的设备发送数据。当我试用演示应用程序时,我看到数据在不同的短暂端口上发送,因为每个事务之后套接字都被关闭,并且下一个事务打开了一个新的套接字。我的应用程序异步发送数据,所以我宁愿在每次事务结束后关闭客户机套接字。但是,我应该每次只在同一个端口发送数据。这让我选择了本地绑定,你认为我可以在没有本地绑定的情况下做到这一点吗?
以上来自于百度翻译 以下为原文 If I do not bind the client to a specific local port, I believe the stack would assign an ephemeral port for every transaction.I will have to advertise my unique ephemeral port (that I should be using for all my transactions) in my SRV record while advertising my service through mDNS much before I start the transaction. The other devices on the network would send data to my device only on this port. When I tried the demo app, I saw that the data was being sent on different ephemeral ports as the socket was closed after every transaction and a new socket was opened for the next transaction. My application sends data asynchronously and so I preferred to close the client socket after every transaction. However, I should be sending data only on the same port every time. This made me opt for a local bind. Do you think I can do this without a local bind? |
|
|
|
只有当新的套接字打开时,堆栈才会分配一个新的临时端口。IMO,在事务之间不应该关闭套接字:它只是低效而不确定它完成了什么:关闭一个套接字,以便以后再打开它。如果你真的需要为你的应用程序拥有一个众所周知的端口,你可以在服务器模式下打开套接字。然后,您可以简单地使这个套接字发送任何东西之前,任何客户端通过指定目的地地址连接到它。大概是一样的东西,但我觉得有点干净。
以上来自于百度翻译 以下为原文 The stack will assign a new ephemeral port only when a new socket is opened. IMO, the socket shouldn't be closed between transactions: it's just simply inefficient and not sure what it accomplishes: close a socket so you can open it again later on. I'd leave it opened for the life of the application. If you really need to have a well known port for your app, you can open the socket in server mode. Then, you can simply make this socket send something before any client connects to it by specifying a destination address. Probably the same thing but a little bit cleaner, I think. |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
734浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
506浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 21:16 , Processed in 1.162153 second(s), Total 59, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号