udp发送完消息后要关闭端口描述符

在UDP通信中,如果不关闭发送消息后的端口描述符,可能导致第二次尝试通信时无法正常接收数据,甚至线程被挂住。正确做法是在发送完毕后记得关闭端口描述符。
摘要由CSDN通过智能技术生成
int get_osd_oob_list(struct osd_node onode, struct list_head *head)
{
	printf("\nEntering %s ", __func__);
	char message[4096];
	char oob_receive_buf[8192];
	int ret, m_type, valid_len;
	int failure_time = 0;
	int socket_descriptor;
	struct sockaddr_in sin;
	int sin_len;
	int port = OSD_RECEIVE_RESULT_PORT;
	int is_cur_osd = (onode.osd_no == current_osd_no) ? 1:0;
	CACHE_INFO("This time being processed osd_node is: no:%d and name %s and current restarted osdno:%d",\
		onode.osd_no, onode.osd_address, current_osd_no);
	CACHE_INFO("+++++++++In line%d and is_cur_osd :%d", __LINE__, is_cur_osd);
	if(onode.osd_no == current_osd_no)
		is_cur_osd = 1;
	CACHE_INFO("++++++++++++++++IN line%d and is_cur_osd :%d", __LINE__, is_cur_osd);
	memset(&sin, 0, sizeof(sin));
	sin.sin_family=AF_INET;
	si
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值