作者maxi326 (不想再留白)
看板PangSir
标题[计网] 关於作业二遇到两个不会解的难题
时间Thu May 5 02:06:00 2005
1.open file传回去为html时很正常
为jpg时,type正确是image/jpg,open file也没问题
但browser没显示图片
问题好像是因为我用fgets去读file
再用send(socket_fd,buff,length,flags);去送出资料
送出去的东西好像跟我gets拿到的不完全一样
有没有人提供可使用的function组合?
2.用select时他好像都不会return,是跟我有用fork有关吗?
select部分的code:
struct timeval timeo;
fd_set rset;
int maxfdp1;
FD_ZERO(&rset);
timeo.tv_sec = 10;
timeo.tv_usec = 0;
FD_SET(fileno(fileO), &rset);
^^file* pointer to opened file
FD_SET(new_fd, &rset);
^^socket for I/O
maxfdp1 = max(fileno(fileO), new_fd) + 1;
if ((sel = select(/*FD_SETSIZE*/maxfdp1, &rset, NULL, NULL, &timeo)) == -1 )
printf("sel error\n");
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.252.59
※ 编辑: maxi326 来自: 140.112.252.59 (05/05 03:20)