cancel
Showing results for 
Search instead for 
Did you mean: 

Can I run TCP Server and Client code simultaneously

aatif shaikh
Associate III

hello!

I've tested the TCP echo server and TCP echo client examples of STM32CubeMX individually and they are working fine. now I want to implement an application where I can use both application simultaneously.

So I copied the TCP echo client code files into TCP echo server's code but unfortunately my code keep getting stuck in some ethernet configuration part. are they using some kind of semaphore or something?

1 ACCEPTED SOLUTION

Accepted Solutions
aatif shaikh
Associate III

I've completed the above task with reference of standard peripheral library "STSW-STM32060" which is much simpler the HAL libraries.

in order to merge two codes follow steps given bellow:

1)copy tcp_echoclient.c + tcp_echoclient.h file from "tcp_echo_client" and paste into the "tcp_echo_server" code folder(scr + inc).

2)open project file of "tcp_echo_server" and add "tcp_echoclient.c + tcp_echoclient.h" into "tcp_echo_server" project.

3) copy the "destination IP address" from main.h present in "tcp_echo_client" project and paste it into the main.h of "tcp_echo_server".

4)call tcp_echoclient_connect() function into main() if "EthernetLinkStatus" flag = 0. if it doesn't get connected immediately you can call tcp_echoclient_connect() after fix interval of time.

5)you can change the SOURCE IP/ GATEWAY/ SUBNET/ DESTINATION IP in main.h and port number in tcp_echoserver_init() and tcp_echoclient_connect().

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32060.license=1541052974344.product=STSW-STM32060.html

View solution in original post

1 REPLY 1
aatif shaikh
Associate III

I've completed the above task with reference of standard peripheral library "STSW-STM32060" which is much simpler the HAL libraries.

in order to merge two codes follow steps given bellow:

1)copy tcp_echoclient.c + tcp_echoclient.h file from "tcp_echo_client" and paste into the "tcp_echo_server" code folder(scr + inc).

2)open project file of "tcp_echo_server" and add "tcp_echoclient.c + tcp_echoclient.h" into "tcp_echo_server" project.

3) copy the "destination IP address" from main.h present in "tcp_echo_client" project and paste it into the main.h of "tcp_echo_server".

4)call tcp_echoclient_connect() function into main() if "EthernetLinkStatus" flag = 0. if it doesn't get connected immediately you can call tcp_echoclient_connect() after fix interval of time.

5)you can change the SOURCE IP/ GATEWAY/ SUBNET/ DESTINATION IP in main.h and port number in tcp_echoserver_init() and tcp_echoclient_connect().

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32060.license=1541052974344.product=STSW-STM32060.html