OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 12728|回复: 4

LWIP 多条socket连接

[复制链接]

26

主题

85

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
235
金钱
235
注册时间
2014-12-18
在线时间
13 小时
发表于 2015-1-16 10:41:01 | 显示全部楼层 |阅读模式
5金钱

小弟目前在搞f107 freertos+lwip,目前遇到的问题是只能成功建立两条socket连接

具体

设备即作为Server、又做Client

2条client可以成功连接到远程server


远程client连接设备的server端是,连接被拒绝,抓包显示窗口大小不够


不知问题出在哪里

是底层驱动问题?内存太小?

请各位大虾指点迷津,小弟在此不胜感激


正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

19

主题

234

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
362
金钱
362
注册时间
2014-7-8
在线时间
10 小时
发表于 2015-1-16 10:53:33 | 显示全部楼层
lwipopts.h 裡面滿多選項都可以調整看看, 因為這關係到 RAM問題, 底下只是些例子, 我板子上可以,
但因為我有外加 RAM , 所以要看你的情況

#define MEMP_NUM_TCP_PCB        15
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
   connections. */
#define MEMP_NUM_TCP_PCB_LISTEN  10 //5
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP

/* TCP Maximum segment size. */
#define TCP_MSS                 (1500 - 40)   /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */

/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF             (5*TCP_MSS)

/*  TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
  as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */

#define TCP_SND_QUEUELEN        (2* TCP_SND_BUF/TCP_MSS)

/* TCP receive window. */
#define TCP_WND                 (20*TCP_MSS) // 2*TCP_MSS
回复

使用道具 举报

26

主题

85

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
235
金钱
235
注册时间
2014-12-18
在线时间
13 小时
 楼主| 发表于 2015-1-16 11:08:43 | 显示全部楼层
回复【2楼】溫柔一刀:
---------------------------------
对您的帮助深表感谢。我修改了一些还是不行,下边是我的配置,这个和网口驱动有关吗?

/* ---------- Memory options ---------- */
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
   lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
   byte alignment -> define MEM_ALIGNMENT to 2. */
#define MEM_ALIGNMENT           4

/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE                (5*1024)

/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
   sends a lot of data out of ROM (or other static memory), this
   should be set high. */
#define MEMP_NUM_PBUF           100
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
   per active UDP "connection". */
#define MEMP_NUM_UDP_PCB        6
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
   connections. */
#define MEMP_NUM_TCP_PCB        10
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
   connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 5
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
   segments. */
#define MEMP_NUM_TCP_SEG        20
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
   timeouts. */
#define MEMP_NUM_SYS_TIMEOUT    10
/**
 * MEMP_NUM_NETCONN: the number of struct netconns.
 */
#define MEMP_NUM_NETCONN                5
/**
 * MEMP_NUM_NETBUF: the number of struct netbufs.
 */
#define MEMP_NUM_NETBUF                 3




/* ---------- buf options ---------- */
/* BUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define BUF_POOL_SIZE          20

/* BUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define BUF_POOL_BUFSIZE       500


/* ---------- TCP options ---------- */
#define LWIP_TCP                1
#define TCP_TTL                 255

/* Controls if TCP should queue segments that arrive out of
   order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ         0

/* TCP Maximum segment size. */
#define TCP_MSS                 (1500 - 40)   /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */

/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF             (5*TCP_MSS)

/*  TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
  as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */

#define TCP_SND_QUEUELEN        (2* TCP_SND_BUF/TCP_MSS)

/* TCP receive window. */
#define TCP_WND                 (10*TCP_MSS)


/* ---------- ICMP options ---------- */
#define LWIP_ICMP                       1


/* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
   interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
   turning this on does currently not work. */
#define LWIP_DHCP               1
#define LWIP_DNS                       0
#define LWIP_SO_RCVTIMEO                0
/* ---------- UDP options ---------- */
#define LWIP_UDP                1
#define UDP_TTL                 255


/* ---------- Statistics options ---------- */
#define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1
回复

使用道具 举报

0

主题

3

帖子

0

精华

新手入门

积分
23
金钱
23
注册时间
2013-4-26
在线时间
0 小时
发表于 2015-6-19 12:51:37 | 显示全部楼层
正确答案是:在os_cfg.h系统配置文件里面修改#define OS_MAX_QS                 4u ,为#define OS_MAX_QS                 6u 
你就可以创建3个socket了。试试吧。
回复

使用道具 举报

1

主题

5

帖子

0

精华

新手上路

积分
45
金钱
45
注册时间
2013-12-13
在线时间
5 小时
发表于 2017-5-3 16:27:59 | 显示全部楼层
我也是这样的问题,求问题解决
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-4-9 01:45

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表