TCP/IP Socket "Time Wait" issue

Coming across an issue where having used up 127 socket then starting again from 0 (lower number) causes Time-Wait issue. When this happens socket is not available until sometime (about 30 to 40 sec).
This is how I’m opening socket and closing socket:-
int skt = socket(AF_INET, SOCK_STREAM, 0);

Have also tried shutting down read write sockets before closesocket(skt):-
shutdown(skt, 0);// read
shutdown(skt, 1);// write

Any help will be appreciated.

which hardware and firmware (version) are you running this on?