My Application is acting as server as well as client.
Server as recieving data from other clent and sending data to another server.
Current scenario is while m sending message to server i am crreating and closing socket after sending.
But the Requirement is to keep the connection of that server when my application is up so that every time to send message i need not to create connection everytime.
From my ending message is going properly and server recieving first message properly but after that next message is not shown on that server log.

Kindly suggest what can be the problem.
Thanking in Advance.

This is a situation where multiple threads may be appropriate. Have a thread for handling incoming messages, and another for communicating with the remote server (don't close the socket if possible). You have a mutex that controls access to the outgoing messages - grab the mutex from one thread, post the outgoing message to a queue, and then close the mutex. The thread that handles the outgoing messages will wait on the mutex, and when it gets it, knows that it can read the message from the queue into a local buffer, release the mutex, and send the message.

Try using state-machine diagrams to analyze these scenarios and to be sure you aren't getting into unresolvable race conditions and such.