(gethostname(hname,sizeof(hname))==SOCKET_ERROR) { printf("gethostname Failed!\n"); printf("Error Code:%d\n",WSAGetLastError()); return -1; } printf("Local Host Name:%s\n",hname); return 0;