rtsp客户端请求数据问题

ykmao10 2012-06-15 11:39:55

int main(int argc ,char **argv)
{
if(argc < 2)
{
printf("the argv is not enough\n");
return 0;
}
int cli_fd;
struct sockaddr_in sevaddr;
sevaddr.sin_family = AF_INET;
sevaddr.sin_port = htons(8554);
sevaddr.sin_addr.s_addr = inet_addr(argv[1]);
//以上设置server地址信息
cli_fd = socket(AF_INET,SOCK_STREAM,0);
if(-1 == cli_fd)
{
printf("client socket set up fail,please check it\n");
return 0;
}
int resault;
resault = connect(cli_fd,(struct sockaddr*)(&sevaddr),sizeof(sevaddr)); //链接服务器
if(-1 == resault)
{
printf("connect the server fail,please check it\n");
return 0;
}
printf("connect server scucess\n");

//rtsp服务器接受的命令数据
char optionbuf[1000] = {"OPTIONS rtsp://192.168.1.104:8554/nxn.mp3 RTSP/1.0 \r\n \
CSeq: 1 \r\n\r\n \
User-Agent: live555 \r\n"};

char describebuf[1000] = {"DESCRIBE rtsp://192.168.1.104:8854/nxn.mp3 RTSP/1.0 \r\n \
CSeq: 2 \r\n \
Accept: application/sdp \r\n\r\n \
User-Agent: live555 \r\n"};
char recvbuf[1000] = {0} ;
/////////////////////////

if(sendto(cli_fd,optionbuf,sizeof(optionbuf),0,NULL,NULL) == -1)
{
printf("send data to server has take error\n");
return 0;
}

if(recvfrom(cli_fd,recvbuf,sizeof(recvbuf),0,NULL,NULL) == -1)
{
printf("recv data from server take error\n");
return 0;
}
printf("%s\n",recvbuf);
memset(recvbuf,0,1000);
if(sendto(cli_fd,describebuf,sizeof(describebuf),0,NULL,NULL) == -1)
{
printf("send data to server has take error\n");
return 0;
}

if(recvfrom(cli_fd,recvbuf,sizeof(recvbuf),0,NULL,NULL) == -1)
{
printf("recv data from server take error\n");
return 0;
}
printf("%s\n",recvbuf);


return 0;
}


代码如上,我现在的问题是为什么我第一次发送option命令的时候返回正确,然后我在发送describe命令的时候就出现服务器返回405的问题,我是过把describe命令放到第一次去发送就成功了,也就是说我这个代码第二次发送总是返回405,求大牛帮忙!!!
...全文
125 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ykmao10 2012-06-16
  • 打赏
  • 举报
回复
来大牛帮我看看啊

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧