MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / tsend_stream

Function tsend_stream

tsend.c:92–119  ·  view source on GitHub ↗

! \brief sends on fd (which must be O_NONBLOCK); if it cannot send any data * in timeout milliseconds it will return ERROR * \return -1 on error, or number of bytes written * (if less than len => couldn't send all) * bugs: signals will reset the timer */

Source from the content-addressed store, hash-verified

90 * bugs: signals will reset the timer
91 */
92int tsend_stream(int fd, char* buf, unsigned int len, int timeout)
93{
94 int written;
95 TSEND_INIT;
96
97 written=0;
98again:
99 n=send(fd, buf, len,
100#ifdef HAVE_MSG_NOSIGNAL
101 MSG_NOSIGNAL
102#else
103 0
104#endif
105 );
106 TSEND_ERR_CHECK("tsend_stream");
107 written+=n;
108 if ((unsigned int)n<len){
109 /* partial write */
110 buf+=n;
111 len-=n;
112 }else{
113 /* successful full write */
114 return written;
115 }
116 TSEND_POLL("tsend_stream");
117error:
118 return -1;
119}
120
121
122

Callers 5

ws_raw_writevFunction · 0.85
jsonrpc_handle_cmdFunction · 0.85
janus_ws_raw_writevFunction · 0.85
tcp_write_on_socketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected