Hi .
I test a pair ipc socket sending / recving function of the nanomsg socket
with two applications. but I can only send 2 "big" packets before fail .
server:
int sock=nn_socket(AF_SP,NN_PAIR);
int recvsndbufsize=1024*1024*1; // set the sending recving buffer size to 1MB
int
rc=nn_setsockopt(sock,NN_SOL_SOCKET,NN_SNDBUF,&recvsndbufsize,sizeof(recvsndbufsize));
rc=nn_setsockopt(sock,NN_SOL_SOCKET,NN_RCVBUF,&recvsndbufsize,sizeof(recvsndbufsize));
rc = nn_bind (sock, "ipc://my.ipc");
client:
int sock=nn_socket(AF_SP,NN_PAIR);
int recvsndbufsize=1024*1024*1;
int
rc=nn_setsockopt(sock,NN_SOL_SOCKET,NN_SNDBUF,&recvsndbufsize,sizeof(recvsndbufsize));
rc=nn_setsockopt(sock,NN_SOL_SOCKET,NN_RCVBUF,&recvsndbufsize,sizeof(recvsndbufsize));
rc = nn_connect (sock, "ipc://my.ipc");
After the server binded and the client connected , I tried to send a big packet
(the size is 10240 bytes ) via nn_sendmsg function:
struct nn_msghdr hdr;
struct nn_iovec iov [1];
char buff[10241];memset(buff,0,sizeof(buff));
for(int i=0;i<10240;i++)
buff[i]='a'+i%21;
iov [0].iov_base = (void*)buff;
iov [0].iov_len = strlen(buff);
memset (&hdr, 0, sizeof (hdr));
hdr.msg_iov = iov;
hdr.msg_iovlen = 1;
int rc = nn_sendmsg (sock, &hdr, NN_DONTWAIT);
but I can only send 2 packets . the third try will fail . why ? the
nn_setsockopt function returns 0 which means the size of sending/recving buffer
size has been changed successfully. 1MB =10240*102 , I should send 102
packets before fail !