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