socket学习笔记——IO口的基本操作(读、写)
写操作
1 #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
void error_handling(char* message); int main()
{
int fd;
char buf[] = "let's go!"; fd = open("1.txt",O_CREAT|O_WRONLY);
if(fd == -)
error_handling("open error");
printf("file descriptor:%d \n",fd); if(write(fd,buf,sizeof(buf)) == -)
error_handling("write error"); close(fd);
return ;
} void error_handling(char* message)
{
fputs(message,stderr);
fputc('\n',stderr);
exit();
}
写操作
1 #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
void error_handling(char* message); int main()
{
int fd;
char buf[];
fd = open("1.txt",O_RDONLY);
if(fd == -)
error_handling("open error");
printf("file description;%d\n",fd); if(read(fd,buf,sizeof(buf)-)==-)
error_handling("read error"); printf("file data:%s\n",buf);
close(fd);
return ;
} void error_handling(char* message)
{
fputs(message,stderr);
fputc('\n',stderr);
exit();
}
socket学习笔记——IO口的基本操作(读、写)的更多相关文章
- html5标签video(播放器)学习笔记(二)-基本操作
html5标签video(播放器)学习笔记(二)-基本操作 subying 发布时间: 2014/12/01 23:59 阅读: 13008 收藏: 21 点赞: 3 评论: 0 摘要 本文介绍了ht ...
- Kettle学习笔记(二)— 基本操作
目录 Kettle学习笔记(一)- 环境部署及运行 Kettle学习笔记(二)- 基本操作 kettle学习笔记(三)- 定时任务的脚本执行 Kettle学习笔记(四)- 总结 打开Kettle 打开 ...
- Java Socket 学习笔记
TCP协议的Socket编程 Socket:英文中的意思是插座.两个Java应用程序可以通过一个双向的网络通信连接实现数据交换,这个双向链路的一端称为一个Socket.Java中所有关于网络编程的类都 ...
- msp430学习笔记-IO及低功耗
引用:http://bbs.ednchina.com/BLOG_ARTICLE_3013511.HTM MSP430F149有6个8位的IO口,其中P1,P2口占两个中断向量,共可以接16个中断源.还 ...
- java学习笔记8--接口总结
接着前面的学习: java学习笔记7--抽象类与抽象方法 java学习笔记6--类的继承.Object类 java学习笔记5--类的方法 java学习笔记4--对象的初始化与回收 java学习笔记3- ...
- 学习笔记:The Log(我所读过的最好的一篇分布式技术文章)
前言 这是一篇学习笔记. 学习的材料来自Jay Kreps的一篇讲Log的博文. 原文非常长.可是我坚持看完了,收获颇多,也深深为Jay哥的技术能力.架构能力和对于分布式系统的理解之深刻所折服.同一时 ...
- Socket学习笔记(一)
1.socket介绍 我们知道两个进程如果需要进行通讯最基本的一个前提能能够唯一的标示一个进程,在本地进程通讯中我们可以使用PID来唯一标示一个进程,但PID只在本地唯一,网络中的两个进程PID冲突几 ...
- C# Socket学习笔记一
小记:刚接触网络编程觉得网络是个神奇的东西,所以对它就很有兴趣,想了解下网络是如何进行进行数据传输的,那么开始第一天的学习吧!ReadyGo!!! 首先我们要了解一下几点内容: 1.网络中进程之间如何 ...
- Java 学习笔记 IO流与File操作
可能你只想简单的使用,暂时不想了解太多的知识,那么请看这里,了解一下如何读文件,写文件 读文件示例代码 File file = new File("D:\\test\\t.txt" ...
随机推荐
- Import SHA2 SSL cert to Windows IIS7
Import SHA2 SSL cert to Windows IIS7 1.You will get 3 piece of certs from GeoTrust, and save them to ...
- TX Textcontrol 使用总结五——添加图片
实现如图所示效果: 实现代码如下所示: 注意,此处不做代码格式化处理... using System;using System.Collections.Generic;using System.Dra ...
- Visual C++ for Linux Development
原文 https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/ Visual C++ fo ...
- Redis数据库?-Redis的Virtual Memory介绍(转)
众所周知,Redis是一个内存数据库,和Memcached类似,所有数据存在内存中,当然,Redis有rdb和appendonlyfile两个落地文件,可以对断电停机等故障下的数据恢复做一些保证.但是 ...
- sbt设置
配置中央仓库 vim ~/.sbt/repositories [repositories] local osc: http://maven.oschina.net/content/groups/pub ...
- @property and retain, assign, copy, nonatomic解析
nonatomic vs. atomic - "atomic" is the default. Always use "nonatomic". I don't ...
- (WPF) MVVM: 动态添加控件及绑定。
比如需要显示一个键盘,里面有各个按键.实现的效果如下: 之前的思路,就是建立一个singleKey的控件,然后在后台用代码动态的添加到父控件里去, 再用代码在后台进行绑定. 这种实现方法并不是真正的M ...
- 宏定义中的##操作符和... and _ _VA_ARGS_ _
1.Preprocessor Glue: The ## Operator 预处理连接符:##操作符 Like the # operator, the ## operator can be used i ...
- DBA_Oralce Enterprise Manager OEM管理应用介绍(案例)
2014-08-16 BaoXinjian
- 3. Windows根据端口查进程---ADB 相关报错 ADB server didn't ACK cannot bind ':5037'
1.ADB server didn't ACK,一般报ADB相关的错误,大部分是端口被占用了 处理方法: 在命令行输入>adb nodaemon server 如果返回: cannot bind ...