Chinaunix首页 | 论坛 | 博客
  • 博客访问: 750274
  • 博文数量: 741
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-18 11:18
文章分类

全部博文(741)

文章存档

2011年(1)

2008年(740)

我的朋友

分类:

2008-09-18 11:31:21

各位大侠,初学linux下c编程,困难重重,还请赐教啊。先谢谢了啊,以下是调试过程:
43        if((connectfd=accept(listenfd,(struct sockaddr *)&client,&sin_size))==-1){
(gdb)
47       process_cli(connectfd,client);
(gdb)

Breakpoint 2, process_cli (connectfd=6, client=
      {sin_family = 2, sin_port = 9603, sin_addr = {s_addr = 1728161984}, sin_zero = "瞱\022繲\006\215?"}) at zfpserverT.c:55
55        printf("You got a connection from %s.",inet_ntoa(client.sin_addr));
(gdb)
56        num=recv(connectfd,file_name,SEND_BUFFER_SIZE,0);
(gdb)
57        if(num==0){
(gdb)
62        file_name[num-1]='\0';
(gdb)
63        printf("The filename the client needs is %s.\n",file_name);
(gdb)
You got a connection from 192.168.1.103.The filename the client needs is 1.mp3.
64        switch(file_name[0])
(gdb)
79                {sourceFile=fopen("/temp/1.mp3","r");
(gdb)
80                 break;
(gdb)
83         leftToSend=sizeof(sourceFile);
(gdb)
84         fseek(sourceFile,0L,SEEK_SET);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x42069267 in fseek () from /lib/tls/libc.so.6
(gdb) where
#0  0x42069267 in fseek () from /lib/tls/libc.so.6
#1  0x080488b6 in process_cli (connectfd=6, client=
      {sin_family = 2, sin_port = 9603, sin_addr = {s_addr = 1728161984}, sin_zero = "瞱\022繲\006\215?"}) at zfpserverT.c:84
#2  0x080487b9 in main () at zfpserverT.c:47
#3  0x42015574 in __libc_start_main () from /lib/tls/libc.so.6

--------------------next---------------------

阅读(915) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~