0

我不是真正的网络精通,所以我有点挣扎。我的网络服务器演示工作正常。现在我正在尝试在 PC 上的 Qt Creator 服务器和板上的一个非常基本的客户端之间构建一个客户端-服务器连接。我抄袭了演示代码来初始化板,然后调用 tcpOpen(),如果找不到服务器(是/否?),我预计它会失败。这是我的 TCPIPCONFIG.H 文件中启用的内容:

#define STACK_USE_ICMP_SERVER           // Ping query and          
#define STACK_USE_ICMP_CLIENT           // Ping transmission capability
#define STACK_USE_GENERIC_TCP_CLIENT_EXAMPLE    // HTTP Client 
#define STACK_USE_TCP_PERFORMANCE_TEST  // Module for testing TCP TX 

在 main 中,我有(记住,从 main() 调用的函数取自演示):

int main(void)
{
static DWORD t = 0;
static DWORD dwLastIP = 0;

static TCP_SOCKET MySocketClient;

// Initialize application specific hardware
InitializeBoard();

// Initialize stack-related hardware components that may be
// required by the UART configuration routines
TickInit();

// Initialize Stack and application related NV variables into AppConfig.
InitAppConfig();

// Initialize core stack layers (MAC, ARP, TCP, UDP) and
// application modules (HTTP, SNMP, etc.)
StackInit();

// Allocate a socket for this client to try and perform pings
// From the internet: You_need_to_enable STACK_USE_DNS in TCPIPConfig.h to use TCP_OPEN_ROM_HOST
MySocketClient = TCPOpen((DWORD)(PTR_BASE)"169.254.13.41", TCP_OPEN_RAM_HOST, 9999, TCP_PURPOSE_GENERIC_TCP_CLIENT);

if(MySocketClient == INVALID_SOCKET)
{while(1){}};

SOCKET_INFO *remoteSockInfo;
remoteSockInfo = TCPGetRemoteInfo(MySocketClient);

etc.

对 TCPOpen() 的调用总是返回 0(当我检查 remoteSockInfo 时这似乎是有效的)。但是,以太网是否插入电路板并不重要……或者我在该呼叫中使用的任何 IP 地址。

在这种情况下,您不希望调用失败吗?

谢谢,

乔·B。

PS:我在公司的 PC 上尝试测试这块板,所以不允许使用任何网络窥探软件(如wireshark)......我很快就会搬到实验室,届时会有更多的自主权。

编辑:我找到了 GenericTCPClient.c 的源代码,并看到 tcpOpen() 调用创建了套接字并正在积极尝试连接到服务器。所以,现在我想我的问题是,板/插座会在这种状态下响应 ping(即,尚未连接到服务器)吗?

4

1 回答 1

0

The board will only respond to Ping if you have enabled Ping in the stack config: (tcpip_config.h)

Edit: I see you enabled it, missed that. I will see what I can dig out of my code that may help.

于 2015-02-10T15:20:38.743 回答