gpt4 book ai didi

sockets - SMTP 和 POP3 SSL 连接

转载 作者:太空宇宙 更新时间:2023-11-03 15:02:41 25 4
gpt4 key购买 nike

我正在使用 libetpan-1.0 开源(邮件库的东西)以“C”语言访问 SMTP 和 POP3。我在 SMTP 和 POP3 中遇到 SSL 连接问题。当我建立 SSL 连接并连接失败时,我的套接字处于 CLOSE_WAIT 状态。这导致长时间后内存泄漏。这是我的命令“netstat -an”的输出。我在 ARM 板上运行这个应用程序。谁能告诉我,我该怎么办?提前致谢。

Here is my code that i am trying. 
pSmtp = mailsmtp_new(0, NULL); (Create new object)
if (SMTP_NO_ERROR != mailsmtp_ssl_connect(pSmtp, "smtp.gmail.com", 465))
{
mailsmtp_free(pSmtp);
}
else
{
// Send Mail
}
So doesn't my work is over after i call function "mailsmtp_free(pSmtp)" or
i have do other stuff to close connection.


~#netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
tcp 1 0 192.168.51.151:4928 98.139.211.125:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4934 98.139.211.125:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2883 98.139.211.125:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4139 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4140 98.138.105.21:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.151.101:2745 TIME_WAIT
tcp 1 0 192.168.51.151:4142 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4143 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3132 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3133 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3134 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3135 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3131 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2115 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3136 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:3137 98.138.105.21:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.151.101:2761 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.151.101:2757 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.151.101:2753 TIME_WAIT
tcp 1 0 192.168.51.151:4083 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4082 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4081 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4080 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4085 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4084 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4075 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4074 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4073 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4072 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4079 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4078 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4077 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:4076 63.250.193.228:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2493 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2492 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2495 98.138.105.21:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2496 98.138.105.21:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52577 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52581 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52585 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52565 TIME_WAIT
tcp 1 0 192.168.51.151:3978 63.250.193.228:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52569 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52573 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52609 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.151.101:2748 TIME_WAIT
tcp 1 0 192.168.51.151:2743 98.139.211.125:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2742 98.139.211.125:465 CLOSE_WAIT
tcp 1 0 192.168.51.151:2744 98.139.211.125:465 CLOSE_WAIT
tcp 94 0 192.168.51.151:3650 74.125.129.108:587 CLOSE_WAIT
tcp 95 0 192.168.51.151:3655 74.125.129.108:587 CLOSE_WAIT
tcp 1 0 192.168.51.151:2250 63.250.193.228:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52578 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52582 TIME_WAIT
tcp 95 0 192.168.51.151:4618 74.125.129.108:587 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52586 TIME_WAIT
tcp 95 0 192.168.51.151:4615 74.125.129.108:587 CLOSE_WAIT
tcp 1 0 192.168.51.151:4353 98.139.211.125:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52590 TIME_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52594 TIME_WAIT
tcp 1 0 192.168.51.151:2769 98.138.105.21:465 CLOSE_WAIT
tcp 0 0 192.168.51.151:80 192.168.51.40:52598 TIME_WAIT
udp 0 0 0.0.0.0:2048 0.0.0.0:*
udp 0 0 0.0.0.0:2049 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 6 [ ] DGRAM 1262 /dev/log
unix 2 [ ] DGRAM 1993
unix 2 [ ] DGRAM 1513
unix 2 [ ] DGRAM 1511
unix 2 [ ] DGRAM 1492

最佳答案

你需要在你身边关闭它们。

CLOSE_WAIT 表示远程端已关闭连接,但您尚未关闭。

查看已接受的答案 here

关于sockets - SMTP 和 POP3 SSL 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18929520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com