Unity3d Socket sourecode
http://www.cnblogs.com/warensoft/tag/unity3d%20http%20socket/
/Files/j349900963/wucl-89953.zip
http://wucl.codeplex.com/
Warensoft Unity3d Communication Lib
this is a high performance communication library for Unity3d,including some easy-to-use httpclasses,andsocket classes. And especially,it brings a totally new method to access to MS SQL SERVER2005+via http protocol.
该类库是专门为Unity3D编写的一个高性能通信库,其中包括了若干十分易于使用的Http通信类以及Socket通信类.另外最特别之处在于,它引入了一全新的,基于Http协议的数据库访问组件,可以轻松访问MS SQL SERVER2005+.
Features
1. Microsoft C# naming standards
微软命名规范
As a C# developer, you will find the that the unity3d naming standard is quite different, and not comfortable. But in this lib, everything (fields, properties, methods, events) you see will goes with Microsoft naming standards.
作为一个C#开发人员,您会发现Unity3d中的命名规范与其他的C#例程中的命名规范大不相同,如字段公有化等.但是在该类库中,所有能够看到的内容(包括字段,属性,方法,事件)全部符合微软命名规范.
2. Communication via Http protocol
基于HTTP协议的通信
Every class which could be used to process http request and response in .net framework ,such as WebRequest, WebClient, will not work in unity3d, instead of them, the only class you can use is the WWW class. For the beginners, the usage of WWW class may seems strange(yeah, in a 3d engine, you need to do in that way), actually, it is totally different from the Microsoft way. And the most painful points are the memory leak when dispose the http resources, and the multithreading concurrency problem(if you create a lot of instance of WWW class at the same time ,then some times the engine will throw an exception:Too Many Threads, and then the application crashes).
在Unity3D中,开发人员只能使用WWW类来处理Http的请求和响应,原有的在DotNet Framework中的WebRequest类和WebClient类,在Unity3D中是无法使用的.对于初学者来讲,WWW类的使用方法有点奇怪(当然,在3D引擎中,你必须这样做), 事实上,WWW类的使用方式与微软的编程风格完全不同. 当然,最令人头疼的是当你释放WWW类所占用的内存资源时,会出现较为明显的内存泄漏, 另外,过多使用WWW类会产生多线程并发问题,当开发人员同时建立多个WWW类的实例来并发访问多个Web资源时,经常会出现Too Many Threads(线程太多)的异常,然后整个系统就崩溃了.
In Warensoft Unity Communication Lib, a totally new class UnityHttpClient will be the best alternative. the HttpClient class simplifies the process of getting response, and it controls the concurrency numbers automatically in the background. Just compare the two types of codes, the 1st type is implemented with WWW class ,and the 2nd type is implemented with HttpClient class:
Warensoft Unity3D通信库为您引入了一个全新代替方案:UnityHttpClient类.使用UnityHttpClient类发送Http请求以及获取响应将变的极为简单,另外,该类在自动在后台控制并发的线程数量.请对比以下两段代码,第一段是使用WWW类实现的,第二段代码是使用UnityHttpClient类来实现的.