MCPcopy Create free account
hub / github.com/PHZ76/RtspServer / SetBlock

Method SetBlock

src/net/SocketUtil.cpp:35–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void SocketUtil::SetBlock(SOCKET fd, int write_timeout)
36{
37#if defined(__linux) || defined(__linux__)
38 int flags = fcntl(fd, F_GETFL, 0);
39 fcntl(fd, F_SETFL, flags&(~O_NONBLOCK));
40#elif defined(WIN32) || defined(_WIN32)
41 unsigned long on = 0;
42 ioctlsocket(fd, FIONBIO, &on);
43#else
44#endif
45 if(write_timeout > 0)
46 {
47#ifdef SO_SNDTIMEO
48#if defined(__linux) || defined(__linux__)
49 struct timeval tv = {write_timeout/1000, (write_timeout%1000)*1000};
50 setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof tv);
51#elif defined(WIN32) || defined(_WIN32)
52 unsigned long ms = (unsigned long)write_timeout;
53 setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&ms, sizeof(unsigned long));
54#else
55#endif
56#endif
57 }
58}
59
60void SocketUtil::SetReuseAddr(SOCKET sockfd)
61{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected