Update socket.h
This commit is contained in:
parent
f53be2884a
commit
cdcfa5687a
@ -69,7 +69,7 @@ struct SockAddr {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char *s = inet_ntop(AF_INET, (PVOID)&addr.sin_addr, &buf[0], buf.length());
|
const char *s = inet_ntop(AF_INET, (PVOID)&addr.sin_addr, &buf[0], buf.length());
|
||||||
#else
|
#else
|
||||||
const char *s = inet_ntop(AF_INET, &addr.sin_addr, &buf[0], buf.length());
|
const char *s = inet_ntop(AF_INET, &addr.sin_addr, &buf[0], buf.length());
|
||||||
#endif
|
#endif
|
||||||
Assert(s != NULL, "cannot decode address");
|
Assert(s != NULL, "cannot decode address");
|
||||||
return std::string(s);
|
return std::string(s);
|
||||||
@ -111,12 +111,12 @@ class TCPSocket {
|
|||||||
*/
|
*/
|
||||||
inline static void Startup(void) {
|
inline static void Startup(void) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsa_data;
|
WSADATA wsa_data;
|
||||||
if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != -1) {
|
if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != -1) {
|
||||||
SockError("Startup");
|
SockError("Startup");
|
||||||
}
|
}
|
||||||
if (LOBYTE(wsa_data.wVersion) != 2 || HIBYTE(wsa_data.wVersion) != 2) {
|
if (LOBYTE(wsa_data.wVersion) != 2 || HIBYTE(wsa_data.wVersion) != 2) {
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
utils::Error("Could not find a usable version of Winsock.dll\n");
|
utils::Error("Could not find a usable version of Winsock.dll\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -136,10 +136,10 @@ class TCPSocket {
|
|||||||
*/
|
*/
|
||||||
inline void SetNonBlock(bool non_block) {
|
inline void SetNonBlock(bool non_block) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u_long mode = non_block ? 1 : 0;
|
u_long mode = non_block ? 1 : 0;
|
||||||
if (ioctlsocket(sockfd, FIONBIO, &mode) != NO_ERROR) {
|
if (ioctlsocket(sockfd, FIONBIO, &mode) != NO_ERROR) {
|
||||||
SockError("SetNonBlock");
|
SockError("SetNonBlock");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int flag = fcntl(sockfd, F_GETFL, 0);
|
int flag = fcntl(sockfd, F_GETFL, 0);
|
||||||
if (flag == -1) {
|
if (flag == -1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user