/* Closes the present (TCP and UDP) socket connection. 
This function sends a shutdown() on the socket in order to disable send() calls (while recv() ones are still allowed). Then, it closes the socket. */
int sock_close(SOCKET sock, char *errbuf, int errbuflen)
/* Closes the present (TCP and UDP) socket connection. 
This function sends a shutdown() on the socket in order to disable send() calls (while recv() ones are still allowed). Then, it closes the socket. */
int sock_close(SOCKET sock, char *errbuf, int errbuflen)
{
	if (shutdown(sock, SHUT_WR))
	{
		sock_geterror("shutdown()", errbuf, errbuflen);
		closesocket(sock);
		return -1;
	}
	closesocket(sock);
	return 0;
}