can I call directly close() without calling shutdown()
You can. shutdown is only necessary if you would like to half-close the connection (i.e. read or write end).
will the close( ) ensure that all the data is delivered to the destination on the outgoing leg and received by the application at the destination
close does in the background what a blocking send does, no more, no less. If that background send fails though, you will not get any error indication.
There is also SO_LINGER socket option you can tweak if necessary:
SO_LINGER
Sets or gets the SO_LINGER option. The argument is a linger
structure.
struct linger {
int l_onoff; /* linger active */
int l_linger; /* how many seconds to linger for */
};
When enabled, a close(2) or shutdown(2) will not return until
all queued messages for the socket have been successfully sent
or the linger timeout has been reached. Otherwise, the call
returns immediately and the closing is done in the background.
When the socket is closed as part of exit(2), it always lingers
in the background.