socket api's behavior is not the same in C and C++

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

socket api's behavior is not the same in C and C++

1,551 次查看
nasihs
Contributor I

new to MCUXpresso IDE and MXRT106x

I added a tchecho example from sdk to my workspace, and rewrote the tcpecho function (which uses netconn api) with socket api. I ran the code on my board, everything was fine.

Then I migrated the source code to a C++ project, well compiled, the PHY initialized successfully, the tcp server ran and debug info was printed as usual. But, the tcp server cant be connected by a client.

However, when I tried the original tcpecho function (written in netconn api) in the c++ project, it still works, which suggested the PHY and tcp stack worked well.

What's the difference between socket api and netconn api in the c++ project?

0 项奖励
回复
6 回复数

1,541 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi @nasihs ,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) What's the difference between socket api and netconn api in the c++ project?
-- Regarding Lwip, the socket api is based on the netconn api actually, which means the scoket api is the abstraction of the netconn api.
To provide the fastest possible support, I'd highly recommend you try to follow the post to convert the C project to C++ project.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复

1,538 次查看
nasihs
Contributor I

Thanks for your attention.

I didn't mean to convert a c projct to c++, I just wondered why the code didn't work as well as it was in C (the program using socket api has something wrong while the other using netconn api works well, and they both run properly in a C project).

On the other side, I followed the steps in the post and got an error when I tried to debug the program: Break at address "0xdeadbeee" with no debug information available, or outside of program code. How could I deal with this error?

0 项奖励
回复

1,529 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply and clarification.
I was wondering if you can upload the complete tcpecho demo project with the socket API, I try to give convert it to the C++ project a try.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复

1,515 次查看
nasihs
Contributor I

Hi, this is the c project which has something wrong being converted to a c++ project.

0 项奖励
回复

1,498 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
Accoring to your statement, server_test_thread works well in the C project, if yes, create a main.cpp that includes the below head file (such as tcpecho.h), then call the tcpecho_init in the C file (tcpecho.c) to call the server_test_thread finally, it should works well.

*/

#ifndef LWIP_TCPECHO_H
#define LWIP_TCPECHO_H
#ifdef __cplusplus
extern "C" {
#endif

void tcpecho_init(void);

#ifdef __cplusplus
}
#endif
#endif /* LWIP_TCPECHO_H */

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复

1,522 次查看
nasihs
Contributor I

Here‘s my c++ project

The tcpecho_thread works but server_test_thread doesnt. You can find the source code in usrApp.

The tcpecho demo project is just a example imported from rt1062 sdk.

Thanks for your patience

 

0 项奖励
回复