ChinaUnix.net
相关文章推荐:

ifstream linux c close

char *cwd; char buf[PATH_MAX+1]; if ((cwd = getcwd(buf,PATH_MAX+1)) == NULL) {perror("pwd");return(-1);} string filename(cwd); filename.append("/test.config"); ifstream aliasfile(filename.c_str(),ios::nocreate); if (!aliasfile.good()) return(-1); int sockfd; string t_ip,t_nename; while (aliasfile >;>;t_...

by mills - C/C++ - 2003-09-17 14:49:32 阅读(725) 回复(1)

相关讨论

本帖最后由 blue_speed 于 2011-09-05 10:01 编辑 close since purpose is done

by blue_speed - IT职业生涯 - 2011-09-02 10:45:18 阅读(7370) 回复(26)

RT,想判断文件是否打开,close(fd)之后FD=?随意?还是?我想关闭后把fd=-1以后继续用不知道可以不

by lonerwolf - C/C++ - 2010-11-16 18:11:49 阅读(3847) 回复(2)

rt,close(fd)之后fd是什么?随意?想利用fd来判断文件打开还是关闭

by lonerwolf - Linux新手园地 - 2012-11-15 15:40:58 阅读(1771) 回复(3)

linux socket关闭连接的方法有两种分别是shutdown和close,首先看一下shutdown的定义 #include int shutdown(int sockfd,int how); how的方式有三种分别是 SHUT_RD(0):关闭sockfd上的读功能,此选项将不允许sockfd进行读操作。 SHUT_WR(1):关闭sockfd的写功能,此选项将不允许sockfd进行写操作。 SHUT_RDWR(2):关闭sockfd的读写功能。 成功则返回0,错误返回-1,错误码errno:EBADF表示sockfd不是一个有效描述符;ENOT...

by lxjeanse - Linux文档专区 - 2009-10-16 23:16:17 阅读(1925) 回复(0)

由于受到syn,close_wait 的功能,我做了以下配置. sysctl -w net.ipv4.tcp_syncookies=1 sysctl -w net.ipv4.tcp_max_syn_backlog=3072 sysctl -w net.ipv4.tcp_synack_retries=1 sysctl -w net.ipv4.tcp_syn_retries=1 sysctl -w net.ipv4.conf.all.send_redirects=0 sysctl -w net.ipv4.conf.all.accept_redirects=0 sysctl -w net.ipv4.conf.all.forwarding=0 sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1 sysctl -w ...

by chenam - Linux新手园地 - 2009-07-14 09:44:05 阅读(2979) 回复(2)

linux上TCP的shutdown/close(备忘) linux的版本是kernel-2.6.21: 1,只要TCP栈的读缓冲里还有未读取(read)数据,则调用close时会直接向对端发送RST。 2,shutdown与socket描述符没有关系,即使调用shutdown(fd, SHUT_RDWR)也不会关闭fd,最终还需close(fd)。 3,可以认为shutdown(fd, SHUT_RD)是空操作,因为shutdown后还可以继续从该socket读取数据,这点也许还[color="#cc0000"]需要进一步证实。 4,...

by inside2004 - Linux文档专区 - 2007-07-10 18:51:09 阅读(667) 回复(0)

/***************************************** * open and close file descriptors * ********************************************/ #include #include #include #include #include #include int main(void) { int fd; char path[]="hello"; if((fd=open(path,O_CREAT|O_TRUNC|O_WRONLY,0644) 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21905/showart_220097.html

by zzxzj2004 - Linux文档专区 - 2006-12-23 16:10:29 阅读(518) 回复(0)

I have a TXT file with contents named test.txt as follow: This is a test 444444 333333 good by! I defined a ifstream variable named inFile and intialized with a string "test.txt", and I defined string outString and an ofstream variable named outFile with "output.txt" for initializing.I used the statements for coping the content of file test.txt into file output.txt as follow: inFile >;>; outStri...

by Tonney8888 - C/C++ - 2004-08-21 13:56:31 阅读(1081) 回复(3)

我使用ifstream 方式来实现文件读写并通过socket发送。现在请问两个问题: 1、socket的send和receive函数,一次发送和接收多少个字节最为合理,效率最高? 2、我如何定位当前文件所要读的位置,就是类似于fseed()的功能,能够分多次把文件读完,每次读一部分并发送。 比较急,在线等待,谢谢

by homegirl - C/C++ - 2006-09-26 17:30:07 阅读(3599) 回复(5)

Dear all: I am going to read a file "data.dat", its content is: [Code] 5 0 2 3 5 2 4 2 4 2 4 3 100 1 3 4 2 3 2 2 3 4 2 200 2 3 5 3 5 4 4 2 4 3 300 2 3 5 2 4 2 4 2 4 2 400 2 3 5 2 3 2 4 2 4 2 500 1 3 5 2 4 2 4 2 3 2 [/code] I want to sepearate the data into three part. The first one is [code] N=5; [/code] The second one is [code] key=[0 2 3 5 2 4 2 4 2 4 ...

by zhshqzyc - C/C++ - 2006-05-30 10:28:02 阅读(2207) 回复(8)