EVT307\EXAM\ETH中 DNS和TCPClient的交接有問(wèn)題啊。。。


我把EVT307\EXAM\ETH中 DNS 獲得的IP填到 TCPCLinet里面,建立不了鏈接啊。。。。

DNS Test
SystemClk:120000000
net version:14
mac addr:38 3b 26 89 50 91
WCHNET_LibInit Success
PHY Link Success
DHCP Success
IPAddr = 192.168.10.101
GWIPAddr = 192.168.10.1
IPAddr = 255.255.255.0
DNS1: 192.168.10.1
DNS2: 0.0.0.0
Host Name = www.findthetime.net
IP= 58.213.45.186
Connecting to: 58.213.45.186
WCHNET_SocketCreat 0
Error: 1D

Error: 17

void WCHNET_DNSCallBack(const char *name, u8 *ipaddr, void *callback_arg)
{
??? u8 i;
??? if(ipaddr == NULL)
??? {
??????? printf("DNS Fail\r\n");
??????? return;
??? }
??? printf("Host Name = %s\r\n", name);
??? printf("IP= %d.%d.%d.%d\r\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
??? memcpy(DESIP, ipaddr, 4);
??? if(callback_arg != NULL)
??? {
??????? printf("callback_arg = %02x\r\n", (*(u8 *)callback_arg));
??? }
??? WCHNET_DNSStop();????????????????????????????????????????????????????????? //stop DNS,and release socket
??? WCHNET_CreateTcpSocket();
??? i = WCHNET_SocketConnect(SocketId);??????????????????????? //make a TCP connection
??? mStopIfError(i);
?? ??????????????????????????????????????????????????? //Create a TCP connection

}


void WCHNET_CreateTcpSocket(void)
{
??? u8 i;
??? SOCK_INF TmpSocketInf;

??? memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
??? printf("Connecting to: %d.%d.%d.%d \r\n", (u16)DESIP[0], (u16)DESIP[1],
?????????? (u16)DESIP[2], (u16)DESIP[3]);

??? memcpy((void *) TmpSocketInf.IPAddr, DESIP, 4);
??? TmpSocketInf.DesPort = desport;
??? TmpSocketInf.SourPort = srcport++;
??? TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
??? TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
??? i = WCHNET_SocketCreat(&SocketId, &TmpSocketInf);
??? printf("WCHNET_SocketCreat %d\r\n", SocketId);
??? mStopIfError(i);



}



熱門(mén)產(chǎn)品 : CH390:以太網(wǎng)控制器芯片

您好,根據(jù)報(bào)錯(cuò)信息很可能是未配置TCP連接個(gè)數(shù),這個(gè)參數(shù)要在net_config.h中配置,如下圖所示的地方。另外通過(guò)這種方式與該服務(wù)器連接也不一定成功,因?yàn)椴恢涝摲?wù)器的TCP listening端口。1.png


感謝!

藥到病除!

就說(shuō)WCH的技術(shù)支持名不虛傳!


DNS Test
SystemClk:120000000
net version:14
mac addr:38 3b 26 89 50 91
WCHNET_LibInit Success
WCHNET_CreateTcpSocket finish
PHY Link Success
DHCP Success
IPAddr = 192.168.10.101
GWIPAddr = 192.168.10.1
IPAddr = 255.255.255.0
DNS1: 192.168.10.1
DNS2: 0.0.0.0
Host Name = www.findthetime.net
IP= 58.213.45.186
Connecting to: 58.213.45.186
WCHNET_SocketCreat 0
TCP Connect Success


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频