MCPcopy Create free account
hub / github.com/axboe/liburing / snd

Function snd

test/232c93d07b74.c:170–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170static void *snd(void *arg)
171{
172 struct params *p = arg;
173 int s0;
174 int ret;
175
176 wait_for_rcv_ready();
177
178 if (p->tcp) {
179 int val = 1;
180
181 s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
182 ret = setsockopt(s0, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
183 assert(ret != -1);
184
185 struct sockaddr_in addr;
186
187 addr.sin_family = AF_INET;
188 addr.sin_port = p->bind_port;
189 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
190 ret = connect(s0, (struct sockaddr*) &addr, sizeof(addr));
191 assert(ret != -1);
192 } else {
193 s0 = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
194 assert(s0 != -1);
195
196 struct sockaddr_un addr;
197 memset(&addr, 0, sizeof(addr));
198
199 addr.sun_family = AF_UNIX;
200 memcpy(addr.sun_path, "\0sock", 6);
201 ret = connect(s0, (struct sockaddr*) &addr, sizeof(addr));
202 assert(ret != -1);
203 }
204
205 if (p->non_blocking)
206 t_set_nonblock(s0);
207
208 struct io_uring m_io_uring;
209
210 ret = io_uring_queue_init(32, &m_io_uring, 0);
211 assert(ret >= 0);
212
213 int bytes_written = 0;
214 int done = 0;
215
216 while (!done && bytes_written != 33) {
217 char buff[SEND_BUFF_SIZE];
218 int i;
219
220 for (i = 0; i < SEND_BUFF_SIZE; i++)
221 buff[i] = i + bytes_written;
222
223 struct iovec iov;
224
225 iov.iov_base = buff;
226 iov.iov_len = sizeof(buff);
227

Callers

nothing calls this directly

Calls 6

wait_for_rcv_readyFunction · 0.85
t_set_nonblockFunction · 0.85
io_uring_queue_initFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected