拷贝/home/test/qnx/qos223/target/qnx7/aarch64le/sbin/sysctl进系统中
https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.utilities/topic/s/sysctl.html
kern.sbmax 默认262144,这个限制住了发送、接收缓冲器大小
./sysctl -w kern.sbmax=1000000 #to 1M 必须先执行
./sysctl -w net.inet.udp.sendspace=233000
./sysctl -w net.inet.udp.recvspace=233000
./sysctl -w net.inet.tcp.sendspace=233000
./sysctl -w net.inet.tcp.sendspace=233000
另外,可直接修改/etc/inetd.conf
https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.utilities/topic/i/inetd.conf.html
测试c语言函数
/* getsndrcv.c:
* getsockopt sample c code
* using getsockopt
* Get SO_SNDBUF & SO_RCVBUF Options:
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
/*
* This function reports the error and
* exits back to the shell:
*/
static void displayError(const char *on_what) {
if (errno != 0) {
fputs(strerror(errno), stderr);
fputs(": ", stderr);
}
fputs(on_what, stderr);
fputc('\n', stderr);
exit(1);
}
int main(int argc, char **argv) {
int z;
int s = -1; /* Socket */
int sndbuf = 0; /* Send buffer size */
int rcvbuf = 0; /* Receive buffer size */
socklen_t optlen; /* Option length */
/*
* Create a TDP/IP socket to use:
*/
s = socket(PF_INET, SOCK_DGRAM, 0);
/*s = socket(PF_INET,SOCK_DGRAM,0); udp使用本行代码*/
if (s == -1) {
displayError("socket(2)");
}
/*
* Get socket option SO_SNDBUF:
*/
optlen = sizeof sndbuf;
z = getsockopt(s, SOL_SOCKET, SO_SNDBUF, &sndbuf, &optlen);
if (z) {
displayError(
"getsockopt(s,SOL_SOCKET,"
"SO_SNDBUF)");
}
assert(optlen == sizeof sndbuf);
/*
* Get socket option SO_SNDBUF:
*/
optlen = sizeof rcvbuf;
z = getsockopt(s, SOL_SOCKET, SO_RCVBUF, &rcvbuf, &optlen);
if (z) {
displayError(
"getsockopt(s,SOL_SOCKET,"
"SO_RCVBUF)");
}
assert(optlen == sizeof rcvbuf);
/*
* Report the buffer sizes:
*/
printf("Socket s : %d\n", s);
printf("Send buf: %d bytes\n", sndbuf);
printf("Recv buf: %d bytes\n", rcvbuf);
close(s);
return 0;
}
/*
* OUTPUT
*
[sgupta@rhel54x64 socket]$ gcc getsndrcv.c -o getsndrcv -lsocket
[sgupta@rhel54x64 socket]$ ./getsndrcv
Socket s : 3
Send buf: 16384 bytes
Recv buf: 87380 bytes
[sgupta@rhel54x64 socket]$
*/