- 什么是套接字?
- socket is a standard way to perform network communication through the OS;
- it is a programmer’s abstraction to take care of details of OSI comm;
- it sends and receives data;
- 有几种不同的套接字?
- steam socket – connection-oriented, reliable (on TCP)
- datagram socket – connectionless, unreliable (on UDP)
- 有那些基本的套接字应用函数?(Linux)
- socket (int domain, int type, int prot)
- create a socket
- return a file descriptor
- domain : spec. protocol family of socket fd
- type : spec. types of socket, e.g. datagram, stream data
- prot : almost always be 0. Selects protocol from family
- connect (int fd, struct sockadd *remothost, scoklen_t addr_length)
- connect a socket to to a remote host
- bind (int fd, struct sockaddr *localadd, socklen_t addr_length)
- binds a socket to local address
- listen (int fd, int backlog_queue_size)
- listens for connection and queue requests into backlog
- accept (int fd, sockadd *remothost, socklen_t *addr_length)
- accepts an incoming request
- send (int fd, void *buffer, size_t n, int flags)
- sends n data from buffer to socket fd
- recv (int fd, void *buffer, size_t n, int flags)
- receive n bytes from socket fd into buffer
- socket (int domain, int type, int prot)
Network Socket (一)
乱写
不知不觉很久没来写博客了,年底了,写点什么吧。。。
一个人的圣诞,一个人的新年,所有的时间都将贡献给论文和paper,所有的快乐,悲伤,焦虑都和论文的进程结合在一起,忽上忽下,不知道自己还能承受多久这样的不安,或许当初选择博士这条路的时候,已经给现在埋下了种子。不过,我不是一个人在战斗,千万的博士生不是都是这样过来的么?看看自己,其实离开目标就几步之遥,或许我把自己估计的太高了,总觉得就再努力一下下,再多发一篇文章,一篇期刊,目标就达到了。
假期里面准备做很多事情,但是我期望不是很高,应为期望高,失望也会越高,尽力吧。。。其实,外面下着大雪,空气冰冷,一个人坐在书桌前,一杯茶或者咖啡,一个笔记本,写作,思考,写作,演算,应该是一件很惬意的事情,或许还有点背景音乐。
我喜欢现在,我喜欢我的论文,我的毕业论文将会给世界带来不同,哪怕是很微小的。。。
Randy Pausch 的最后一节课
前一段时间偶尔看到了Randy Pausch去世的消息,心里不是滋味,这位乐观的斗士最终没有战胜病魔离开了他的家庭,离开了他深爱的科研。 最初知道Randy Pausch是在Youtube上看到他在CMU的最后一课。在他得知自己得了癌症,并且已经扩散的时候,他决定用上最后一节公开课的方式来告别他的讲台,告别他钟爱的卡内基迈隆大学。
在一小时十五分钟的课程中,他没有涉及到很多关于专业的的话题,而是给大家上了一堂关于生活的课,演讲的题目就是实现你儿时的梦想(really archieving your childhood dreams)。每个人小时候都有很多梦想,Randy曾经有的梦想是做宇航员,拥有大量的绒毛玩具,参加国家足球俱乐部,到迪斯尼做计算机动画。对于他的每一个儿时的梦想,他几乎都做到了,当然,他最终没有加入国家足球俱乐部,但是他努力了,他没有到迪斯尼做他的虚拟现实,但是他和迪斯尼公司签署了一个协议,所以他手下的毕业生,都能在迪斯尼得到一个位子,他帮别人实现了梦想。虽然没有最终上太空,但是他曾经和他指导的学生一起参加了美国宇航局的失重试验。在实现自己梦想的过程中,Randy谈到了很多所谓的砖墙(brick wall),这些砖墙处处都是,阻止我们去实现自己的梦想,但是,这些砖墙的存在是有理由的,它是我们决心的试金石,给我们机会证明,我们是多么渴望实现我们的梦想 (Brick walls are there for a reason: they let us prove how badly we want to archieve our dreams.).
在整个演讲的过程中,整个大厅充满了笑声,完全没有一个濒临死亡的人在讲他一辈子中最后一节课的感觉, Randy脸上总是笑容满面,他是快乐的,应为他不仅仅实现了他儿时很多梦想,而且他帮助别人实现了他们的梦想。他一开就说道,他不需要同情,应为他很快乐,快乐的人是幸福,即使他面对死亡。。。
有梦想的人更是幸福的,不管那些梦是多么藐小,或者多么遥不可及,能做梦,总有希望的。孩子总是幸福的,应为他们能有彩色的梦想,漫无边际,海阔天空。成长使我们慢慢失去了自己的梦想,活在一个再现实也不过的世界中,那些曾经的梦想被一个一个砖墙给打的支离破碎,于是我们随波逐流,不敢再去梦想,在一个狭隘的空间中维持着,也许我们缺乏Randy那样的勇气,我们是输那些砖墙前面,应为我们不够坚强,不够果断, 也许我们是畏首畏尾?Randy教给我了很多,他让我去思考,思考那些梦想,再次给予他们生命,图上色彩,让他们飞翔。。。
Randy,一路走好。。。
04.10.2008 深夜。
那些回也会不去的青春
三十, 三个十年象一杯颜色分明的鸡尾酒, 每一层都有它独特的味道, 青涩的, 甜蜜的,充满幻想憧憬的,苦涩的. 怀念那些回也回不去的青春年华, 那些无畏无惧是时候.
一个人的闯荡是辛苦和快乐的, 回头看看走过的路, 弯弯曲曲, 往事象照片一张一张呈现眼前, 渐渐的他们变成黑白, 慢慢逝去, 抓不住. 那些笑脸, 我的朋友和敌人.
老家弄堂那幢伴我度过童年和少年的破旧楼房早已拆除了, 弄堂里那些玩伴也不知去向, 走过那里, 又能看到那些脸庞, 和我打过架的, 一起淌弄堂里水坑的, 玩儿打仗的, 玩儿玻璃球的, 幻想开太空飞船的, 一起放鞭炮的, 一起排队回家的路友, 一起上学下学的, 一起在门口那口井里冻西瓜的, 一起在楼里墙上画画的… … 不知道他们还好么… 是不是一样的无奈, 是不是一样的怀念着过去. 那些弄堂里的妹妹是不是都嫁人了, 为人妇的她们是不是还是那么漂亮, 破庙改成的小学校里的是不是还是那么热闹, 他们还能看到用石碑改的台阶么? 石碑上的隶书还能看出来么? 老师们都是否还健在? 孩子们下学的时候是不是还是排成一排回家? 下课的时候他们还用削铅笔刀在泥地上玩插地皮么? 下雨的时候教室屋檐上的水滴下来还能汇成一个大水沟么? 孩子们还用蜡笔改成船, 用圆珠笔的油做动力做船么? 他们还知道用树叶做书签么?
曾经的伙伴们会不会象我一样, 在某个深夜里, 想起这些?
家里朝西的窗开出来, 看见的再也不是那座青山, 那个亭子. 出去再也看不见那条坑坑洼洼的石子路. 那些无忧无虑的日子也象西窗的那座山, 再也看不见了.
现在的我,变了么? 还快乐么? 我不知道… …
长大快乐么? 我不知道… …
这一切的一切是对的么? 我不知道… …
想回到过去么? … …
用邮件简明交流的七条规则
- 使用最少的句子来描述一件事情.
- 开门见山.
- 关注一件事情.
- 用直接的语句,少用感情话语.
- 使用”如果…就”结果, 考虑到尽可能多的假设情况.
- 在发出之前检查歧异, 清晰度.
- 检查邮件的简明性.
1. Use the minimum amount of sentences. I’ve been using the 5-sentence rule, but you can use more if needed. The question is: how many sentences are needed to communicate what you’re trying to communicate? Or how few sentences can you get away with. Cut it to that number, and no more. That ensures that you’re not wasting the time of the recipient, and that your email actually gets read (people tend to put off reading longer ones, and might even delete them).
2. State what you want right away. Don’t write a long introduction, telling your life story, or any story for that matter. People aren’t interested. They just want to know what you want. So state that, in the first sentence. Skip the niceties. Don’t make the recipient wade through 10 paragraphs to find what action is needed for the email.
3. Write about only one thing. There have been numerous times when I read an email, saw the action needed, and went and did it … only to find out that three other things were also needed to respond to the email. I’ve also responded to the first part of an email and not to others, just because I didn’t have enough time.
If you write about multiple things, with multiple requests, you do two things: 1) make it likely that your email actually won’t be read or acted on; and 2) make it likely that even if it is acted on or responded to, the recipient will only do one of those things.
Instead, stick to one subject, with one request. Once that’s done, you can send a second one, but don’t overwhelm the recipient if at all possible.
4. Leave out the humor and emotions. These don’t come across well in an email. Even if you use emoticons. There’s just no way to express tone, inflection, etc. … and there’s no way to know if the recipient understands that you’re joking. If you’re communicating in person, you can see that the person didn’t understand the humor, and say, “I was only joking!” But not in email.
So, unless you know the person well, and you know they’ll understand that you’re joking, leave out humor. It’s a risk that you don’t want to take.
5. Use “If … then” statements. As email is a back-and-forth method of communicating, and it can take a day or more for a response (in some cases), you want to limit the number of times a message has to go back and forth. To do that, use “if … then” statements, anticipating the possible responses to your question.
For example, if you want to know if a person has received a response to an inquiry, instead of asking if they’ve received a response, and then waiting for a reply, and then sending another email based on that reply, try doing it all in one email:
“Have you received a response from Mr. X yet? If so, please finish the report by Tuesday and email it to me. If not, can you follow up today and let me know the response?”
By anticipating the possible responses, and giving a desired action for each possible response, you’re cutting a lot of wasted back-and-forth time.
6. Review for ambiguity, clarity. Once you’ve written an email, take a few seconds to read over it before pressing the Send button. Read it as if you were an outsider — how clear it it? Are there any ambiguous statements that could be interpreted the wrong way? If so, clarify.
7. Revise for conciseness. As you review, also see if there is a way you can shorten the email, remove words or sentences or even paragraphs. Leave nothing but the essential message you’re trying to communicate.
初读Linux内核技术手册
相对于别的linux大部头来说, 这本OReilly的Linux内核技术手册是短到再不能短了, 但是OReilly继承了一贯的传统 – 短小精悍. 这本书的作者本身是Kernel Hacker in trade. 职业内核黑客, 就象他在书的开端写的一样, 在他看来, 好多东西都是顺理成章的东西, 但是他身边的人总是提醒他, 不是每个人都是内核黑客, 要让更多的人加入到内核开发的行列里面来, 就要让他们从了解内核开始, 要让他们知道, 内核是实实在在的东西, 后面并没有什么魔术. 他的书做到了这一点.
有的人说, 要了解内核, 那你可以去网站看啊, 网络上有很多关于内核的站点. 但是仔细看过这些网站的人很容易就发现, 好多内容都过时的, 而且对内核的描述都不是很完整, 要搜索一点信息可能要阅读好多不同的地方, 每个人描述方法又不一样, 很多时候让人无所适从. 这本技术手册的目的之一就是成为一个one-stop-reference. 囊括所有关于内核调试的信息, 同时不深入探讨内核的代码. 这本书刚看了一半, 觉得以前好多比较模糊的概念变的清晰了, 以前看Robert Love和Bovet的大部头, 觉得只有点没有面.
还没有完全看完, 第一和第二部分是重点, 第三部分是Reference, 可以以后慢慢看.
开始用Webblog Client
观望了很久, 看了无数的对Webblog Client的评价, 现在才开始使用Webblog Client写Blog. 觉得比用Web Interface方便多了. 现在在试的是Flock, Windows Live Writer. 用WLW是应为很少有Blog Client支持MSN Spaces. Linux下面用几个比较简单的clients. 顺便说一句WordPress和Blogger还是不错的.
WordPress 继续Python, Linux, UML, 开发模式, AI的文章和笔记.
- Python
- UML 2.0
- OOD&OOA
- Linux
到底什么是UML
UML(Unified Modeling Language) 可以直接 翻译成统一建模语言. 对于UML我觉得可以通过
它的命名来更好的理解:
- U like Unified: 统一是什么意思呢. 我们可以从几方面来理解:
- UML综合和很多以往面对对象方法中被普遍接受的概念, 并给予它们清晰的定义, 表示法和术语
- 支持软件开发周期中的无缝性. 在开发不同阶段可以用同一套概念和方法
- UML可以用于不同领域的建模.
- 编程语言以及开发平台的无关性
- 不对开发过程的细节进行描述
- M like Modeling: 建模
- 模型是对系统结构和含义的一般性说明
- 模型是对现实世界的抽象, 很多现实系统中的细节在建模中间不被考虑. 比如说设计一个基于ATM交易系统, ATM传输协议在建模时候不会被考虑
- 系统是模型的外延
- L like Language:语言
- UML是一种语言, 但是并不是编程语言, 而是一种规范语言(specification language)
- 规范语言一般用于对系统的分析, 需求的分析等等高层次的描述, 实现系统不在规范语言的应用范畴.
(不断完善中)
