Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force partial writes to test a network server

Tags:

c

tcp

sockets

I have a written an event driven server (request response protocol - HTTP like) using non blocking sockets. I tested partial reads by writing a client that sends the request in discrete chunks after every few seconds. How do I test partial writes i.e. I need to write 100 bytes and then send call returns with only 10 bytes written.

I am writing perl based clients. This is over SSL but for the purposes of this question, I am ok with partial writes on TCP.

like image 377
doon Avatar asked Nov 04 '22 15:11

doon


1 Answers

Try to reduce the size of the output buffer:

 err = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 1)

This should make send output only part of the buffer.

like image 91
Jan Wrobel Avatar answered Nov 09 '22 09:11

Jan Wrobel