MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / IsSocketReady

Function IsSocketReady

PanzerChasm/net/net.cpp:36–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34typedef uint32_t IpAddress; // Ip address in net byte order.
35
36static bool IsSocketReady( const SOCKET& socket )
37{
38#ifdef _WIN32
39 fd_set set;
40 set.fd_count= 1u;
41 set.fd_array[0]= socket;
42
43 timeval wait_time;
44 wait_time.tv_sec= 0u;
45 wait_time.tv_usec= 0u;
46
47 const int result= ::select( 0, &set, nullptr, nullptr, &wait_time );
48 if( result == 1 )
49 return true;
50 else if( result == 0 )
51 return false;
52 else
53 {
54 Log::Warning( FUNC_NAME, " - ::select call error: ", ::WSAGetLastError() );
55 return false;
56 }
57#else
58 fd_set set;
59 FD_ZERO(&set);
60 FD_SET( socket, &set );
61
62 timeval wait_time;
63 wait_time.tv_sec= 0u;
64 wait_time.tv_usec= 0u;
65
66 const int result= ::select( socket + 1u, &set, nullptr, nullptr, &wait_time );
67 if( result == 1 )
68 return true;
69 else if( result == 0 )
70 return false;
71 else
72 {
73 Log::Warning( FUNC_NAME, " - ::select call error: ", errno );
74 return false;
75 }
76#endif
77}
78
79bool InetAddress::Parse( const std::string& address_string, InetAddress& out_address )
80{

Callers 4

ReadRealiableDataMethod · 0.85
ReadUnrealiableDataMethod · 0.85
TryCompleteConnectionMethod · 0.85
GetNewConnectionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected