一些随笔 No.1
耦合
耦合是一个设计与逻辑上的问题
例如一个软件有20个功能,删除任意一个功能对别的19个功能不造成影响,就是低耦合
如果删除一个功能后其他功能会失去完整性,那么就是高耦合
Difference between Binary code and ASCII
1) Binary code is a general term used for a method of encoding characters or instructions, but ASCII is only one of the globally accepted conventions of encoding characters and was the most commonly used binary encoding scheme for more than three decades.
2) Binary code can have different lengths for encoding depending on the number of characters, instructions, or the encoding method, but ASCII uses only 7 digits long binary string and 8 digits long for extended ASCII.
登录和连接
前端是命令执行体,所有控制策略都是在服务端
当建立连接后,客户端处于受控状态,处理服务端发来的数据
客户端只是动作的转接者(模拟用户的行为)
当当前连接断开,每产生一个新连接就将状态转为未登录
2. 一个客户端和服务端用多个连接
用签名来区别一个客户端
tcp的模型是流(管道模型) send出去后receive后的可能不是一个东西,可能会夹着别的东西
tcp发送时要校验发送了多少字节
消息队列实现线程间的通讯, 队列里面要有互斥信号量和同步信号量
Little-Endian and Big-Endian in Java
We must have heard these terms Little-Endian and Big-Endian many times in your engineering course. Let’s quickly recap the concept behind these words.
1. Little-Endian vs Big-Endian
These two terms are related to the direction of bytes in a word within CPU architecture.
Computer memory is referenced by addresses that are positive integers. It is “natural” to store numbers with the least significant byte coming before the most significant byte in the computer memory.
Sometimes computer designers prefer to use a reversed order version of this representation.
The “natural” order, where less significant byte comes before more significant byte in memory, is called little-endian.
Many vendors like IBM, CRAY, and Sun preferred the reverse order that, of course, is called big-endian.
2. Example of ordering
For example, the 32-bit hex value 0x45679812 would be stored in memory as follows:
 Address         00  01  02  03
 -----------------------------------
 Little-endian   12  98  67  45
 Big-endian      45  67  98  12
3. Endian-ness in Java
The difference in endian-ness can be a problem when transferring data between two machines.
Everything in Java binary files is stored in big-endian order. This is sometimes called network order. This means that if you use only Java, all files are done the same way on all platforms: Mac, PC, UNIX, etc. You can freely exchange binary data electronically without any concerns about endian-ness.
The problem comes when you must exchange data files with some program not written in Java that uses little-endian order, most commonly a program written in C. Some platforms use big-endian order internally (Mac, IBM 390); some uses little-endian order (Intel).
点对点建立连接方式
方式一
- 
先用UDP实现广播,找出所有通信设备(要规定固定端口) 
- 
找出通信设备后,获取相应的IP信息进行TCP连接,进行点对点的TCP连接 
方式二
设置好指定IP和端口直接通过TCP进行点对点连接

 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号