This is the second part of the previous article about the socket programming. In the earlier article we created a client but that client used to make blocking IO calls ( Receive ) to read data at regular intervals (via clicking the Rx button). But as I said in my earlier article, that model does not work very well in a real world application. Also since Windows is an events-based system, the application (client) should get notifications of some kind whenever the data is received so that client can read it rather than client continuously polling for data.

Well that is possible with a little effort. If you read the first part of this article, you already know that the Socket class in the Systems.Net.Sockets namespace has several methods like Receive and Send which are blocking calls. Besides there are also functions like BeginReceive , BeginSend etc. These are meant for asynchronous IO . For example , there are at least two problems with the blocking Receive:

When you call Receive function the call blocks if no data is present, the call blocks till some data arrives. Even if there is data when you made the receive call , you don't know when to call next time. You need to do polling which is not an efficient way.

Socket Programming in C#--Introduction的更多相关文章

  1. [PHP-Socket] Socket Programming in PHP

    Simple Client-Server socket program in PHP Introduction Sockets are used for interprocess communicat ...

  2. Socket Programming in C#--Conclusion

    Conclusion And that's all there is to it! Here is how our client looks like Here is how our server l ...

  3. Socket Programming in C#--Getting Started

    Getting Started You can argue that one can overcome these shortcomings by multithreading meaning tha ...

  4. How To: Perl TCP / UDP Socket Programming using IO::Socket::INET

    http://www.thegeekstuff.com/2010/07/perl-tcp-udp-socket-programming/ In this article, let us discuss ...

  5. Socket programming in C on Linux | tutorial

    TCP/IP socket programming This is a quick guide/tutorial to learning socket programming in C languag ...

  6. C Socket Programming for Linux with a Server and Client Example Code

    Typically two processes communicate with each other on a single system through one of the following ...

  7. Python Socket Programming

    本文介绍使用Python进行Socket网络编程,假设读者已经具备了基本的网络编程知识和Python的基本语法知识,本文中的代码如果没有说明则都是运行在Python 3.4下. Python的sock ...

  8. linux c socket programming

    原文:linux c socket programming http://54min.com/post/http-client-examples-using-c.html 好文章 PPT http:/ ...

  9. TCP Socket Programming in Node.js

    TCP Socket Programming in Node.js Posted on October 26th, 2011 under Node.jsTags: Client, node.js, S ...

随机推荐

  1. ListView属性整理

    stackFromBottom属性,这只该属性之后你做好的列表就会显示你列表的最下面,值为true和false android:stackFromBottom="true"   第 ...

  2. Android根据APP包名启动应用

    public void openApp(String packageName, Context context) { PackageManager packageManager = context.g ...

  3. 演示 pull解析的基本步骤(代码演示)

       pull解析器:            * 反序列化:将xml中的数据取出                1.导入jar包                2.创建解析器工厂           ...

  4. C语言错误之--初始值(低级错误)

    今天犯了一个低级错误,虽然低级,但是也不能忽视,一个低级错误以后可能小则浪费时间和精力,大则酿成整个app的项目bug.    

  5. oracle中replace、length、lengthb、substr、substrb函数

    1.replacereplace(x,y,z)返回值为将字符串X中的Y串用Z串替换后的结果字符串. replace(x,y)返回值将字符串X中为Y串的地方删除例:epacel('aaabbb','bb ...

  6. 问题解决——在结构体中使用set保存结构体数据

    =====================声明========================== 本文原创,转载请明确的注明出处和作者,并保持文章的完整性(包括本声明部分). 本文链接:http:/ ...

  7. maven 仓库搜索添加需要的jar包

    可用仓库网址: http://search.maven.org/#browse http://mvnrepository.com/ http://repository.sonatype.org/ind ...

  8. eclipse 快捷键Alt+/ 不能补充syso

    通过两步来解决 1:Window->Preferences->General->Keys,输入content assist,把Binding改成alt + / 2:在下面,有一个wh ...

  9. GUID分区与MBR分区

    1.MBR分区表类型的磁盘主引导记录(Master Boot Record,缩写:MBR),又叫做主引导扇区,它仅仅包含一个64个字节的硬盘分区表.由于每个分区信息需要16个字节,所以对于采用MBR型 ...

  10. 在EntityFramework6中执行SQL语句

    在EntityFramework6中执行SQL语句 在上一节中我介绍了如何使用EF6对数据库实现CRDU以及事务,我们没有写一句SQL就完成了所有操作.这一节我来介绍一下如何使用在EF6中执行SQL语 ...