Unix-domain-socket详解UDP(二)

2014-11-24 01:09:18 · 作者: · 浏览: 15
ss_udp));
server_address_udp.sun_family = AF_UNIX;
strcpy(server_address_udp.sun_path, SOCK_UNIX_VIDEO_STREAM_FILE_SEVER);


joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp = 0;
joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp = client_sockfd;


printf("%s %d The udp mode send to jss succeed ,joseph_ipnc_s_socket_fd_udp is %d !\n",__FUNCTION__,__LINE__,joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp);


#endif
return 0;
}



void net_send_stream_first(void *video_buf,int video_length)
{
int s_length;


#if 0
if(video_length <= 8) return;
#else
if(video_length <= 4) return;
#endif



if(joseph_ipnc_s_socket.joseph_ipnc_s_scoket_sta == 1)
{


#if 1
char buf_time[128] = {0};
memset(buf_time,0,128);
get_current_time(buf_time);

printf("%s %d %s send begin time is : \n",__FUNCTION__,__LINE__,buf_time);

printf("%s %d The num is %d ,The buf size is %d !\n",__FUNCTION__,__LINE__,joseph_ipnc_param.joseph_ipnc_network_attr.joseh_send_to_jss_frame_num,video_length);

printf("%s %d joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp is %d \n",__FUNCTION__,__LINE__,joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp);

#endif


#if 0

s_length = send(joseph_ipnc_s_socket.joseph_ipnc_s_scoket_fd, video_buf, video_length, 0);
#else
/*
int sendto ( socket s , const void * msg, int len, unsigned int flags, const struct sockaddr * to , int tolen ) ;
sendto(sockfd, buffer, len, 0, (struct addr*)&addr, addr_len); ±
*/


s_length = sendto(joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp, video_buf, video_length, 0,(struct sockaddr*)&server_address_udp,SUN_LEN(&server_address_udp));


#endif


if(s_length <= 0)
{
printf("%s %d The send is err, The length is %d !!! \n",__FUNCTION__,__LINE__,s_length);
close(joseph_ipnc_s_socket.joseph_ipnc_s_scoket_fd);
//close(joseph_ipnc_s_socket.joseph_ipnc_s_socket_fd_udp);
joseph_net_lock();
joseph_ipnc_s_socket.joseph_ipnc_s_scoket_sta = -2;
joseph_net_unlock();
//exit(-2);


}
else
{
//printf("%s %d net_send_stream_first succeed \n",__FUNCTION__,__LINE__);
//do nothing
}


#if 0
memset(buf_time,0,128);
get_current_time(buf_time);

printf("%s %d %s send end time is : \n",__FUNCTION__,__LINE__,buf_time);

#endif


}
else
{


// do nothing


}



}