HP-Socket v3.2.2

摘要:
=============================================================================v3.2.2升级:=============================================================

==========================================================================================
v3.2.2 upgrade :
==========================================================================================

> Increase some methods for helps:
-----------------

  1. Batch sending methods: SendPackets()
        1) IClient / IServer / IAgent add the sending methods: SendPackets(dwConnID, pBuffers[], iBufferCount)
        2) For TCP component - send all packets in order
        3) For UDP component - make all the packets combined into one packet and send (the length of the packet can not be greater than the maxinum of length of a UDP packet which is set up)
  2. small files sending methods: SendSmallFile()
        1) ITcpClient / ITcpServer / ITcpAgent add the small files sending methods: SendSmallFile(dwConnID, lpszFileName, pHead, pTail)
        2) By the parameters: pHead and pTail,each can add some definitions int the files heads and tails
        3) SendSmallFile() only send the files whose size small than  4096 KB
  3. HPSocket.dll and HPSocket4C.dll add following export methods:
        1) SYS_WSAGetLastError():call the system's WSAGetLastError()
        2) SYS_SetSocketOption():call the system's setsockopt()
        3) SYS_GetSocketOption():call the system's getsockopt()
        4) SYS_IoctlSocket()           :call the system's ioctlsocket()
        5) SYS_WSAIoctl()               :call the system's WSAIoctl()

> update instructions:
-----------------

  1. HP-Socket v3.2.1 or previous versions for applications can upgrade to HP-Socket v3.2.2 safely

==========================================================================================
v3.2.1 upgrade:
==========================================================================================

> add communication components TcpAgent / TcpPullAgent :
-----------------

  1. for the proxy server and transit server etc. , server can be the client and launche a large-scale service connections to other servers.
  2. TcpClient / TcpPullClient basic on  Event Select communication model,every component object manages one Socket and open a thread ,but the above scenario is not suitable.
  3. TcpAgent / TcpPullAgent basic on IOCP communication model,one componet object manages many Sockets,for the clients communication components of the proxy server and transit server.
  4. TcpAgent / TcpPullAgent methods are easy to use and provide following interface methods:
         1) notice interface methods:
           OnPrepareConnect(CONNID dwConnID, SOCKET socket)
            OnConnect(CONNID dwConnID)
            OnSend(CONNID dwConnID, const BYTE* pData, int iLength)
            OnReceive(CONNID dwConnID, const BYTE* pData, int iLength)    //(Push model)
            OnReceive(CONNID dwConnID, int iLength)                        //(Pull model)
            OnClose(CONNID dwConnID)
            OnError(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode)
            OnAgentShutdown()
         2) main operating methods:
           Start(LPCTSTR pszBindAddress = nullptr, BOOL bAsyncConnect = TRUE)
            Stop()
            Connect(LPCTSTR pszRemoteAddress, USHORT usPort, CONNID* pdwConnID = nullptr)
            Send(CONNID dwConnID, const BYTE* pBuffer, int iLength, int iOffset = 0)
            Disconnect(CONNID dwConnID, BOOL bForce = TRUE)
            Fetch(CONNID dwConnID, BYTE* pData, int iLength)    //(Pull model)
  5. add TcpAgent / TcpPullAgent excemples for user:
        1) Agent-PFM
        2) Agent-Pull
        3) Agent-4C
  6. add TcpAgent + TcpServer HTTP proxy server excemple:HttpProxy

> add HPSocket for Java SDK:
-----------------

  1. provide Java development package:hpsocket-3.2.1.jar(by JNA ,now only supports Windows platform)
  2. running environment:JDK 1.6+,JVM runs server mode("java -server",in client mode,the properties affected)
  3. add the project TestEcho-4J,show the HPSocket4J using methods (includes Pull model examples and sample performance tests)
  4. MBCS and Unicode version are in the jars: org.jessma.hpsocket.mbcs and org.jessma.hpsocket.unicode
  5. HPSocket for Java SDK provides following communication components :
        1) TcpServer:TCP communication server component ,supports  PUSH/Pull model
        2) TcpClient:TCP communication client component ,supports  PUSH/Pull model
        3) TcpAgent :TCP communication  Agent component ,supports  PUSH/Pull model
        4) UdpServer:UDP communication server component ,supports  Push model
        5) UdpClient:UDP communication client component ,supports  Push model
  6. HPSocket4J using methods (using TcpAgent for example):
       /* 0: add the jars into the project: hpsocket-3.2.1.jar and jna-4.1.0.jar */
       
        /* 1: create communication component object  */
        TcpAgent agent = TcpAgent.create(Mode.PUSH);
       
        /* 2: set the callback function object  */
        // (optional )
        agent.setCallBackOnPrepareConnect(new OnPrepareConnectImpl());
        // (optional )
        agent.setCallBackOnConnect(new OnConnectImpl());
        // (required )Push model need to set OnReceive callback function object
        agent.setCallBackOnReceive(new OnReceiveImpl());
        // (required )Pull model need to set OnPullReceive callback function object
        // agent.setCallBackOnPullReceive(new OnPullReceiveImpl());
        // (optional )
        agent.setCallBackOnSend(new OnSendImpl());
        // (required )
        agent.setCallBackOnClose(new OnCloseImpl());
        // (required )
        agent.setCallBackOnError(new OnErrorImpl());
        // (optional )
        agent.setCallBackOnAgentShutdown(new OnAgentShutdownImpl());
       
        /* 3:start communication component  */
        agent.start("127.0.0.1", false);
       
        /* 4:connect server */
        agent.connect("localhost", (short)5555, pdwConnID);
       
        /* 5:handle communication data */
        // response OnReceive / OnPullReceive events and receive data
        // use    agent.send(dwConnID, data, data.length) to send data
       
        /* 6:close communication component  */
        agent.stop();
       
        /* 7:destroy communication component  */
        TcpAgent.destroy(agent);

> optimize data transmission / reception strategies:
-----------------

  1. Server and Agent components provide the following three types of data transmission policy:
        1)PACK - packing mode(default)    :try to send data formmultiple operetions together to send and add transmission efficiency.
        2)SAFE - sage mode        :try to make data formmultiple operetions together to send,control the transmission rate ,and avoid buffer overflow
        3)DIRECT - direct mode        :each sending operation is delivered directly ,for when the loading is not high but it requires real-time high places.
  2. Server and Agent components provide the following two data-accept events:
        1)SERIAL - serial mode(default):trigger the same connection in the order: OnReceive and OnClose/OnError event
        2)PARALLEL - parallel mode    :in different communication threads , trigger the same connection OnReceive and OnClose/OnError event in the same time

> other updates :
-----------------

  1. IServer' GetClientAddress() method changes the name to : GetRemoteAddress()
  2. IClient' Send() method deletes the parameter: “CONNID dwConnID”
  3. IClient/IServer/IAgent' Send() method adds the pointer offset parameter “int iOffset” for sending data buffer
  4. add EnSendPolicy enumerated type,IServer/IAgent add sending mode setting method: SetSendPolicy()
  5. add EnRecvPolicy enumerated type,IServer/IAgent add receving mode setting method: SetRecvPolicy()
  6. IServer/IAgent add method:BOOL GetAllConnectionIDs(),get all connected CONNID
  7. IUdpServer add method:SetPostReceiveCount(),set Receive Number of predelivery
  8. EnServerError / EnClientError enumerated type unite into EnSocketError
  9. EnSocketError / EnHandleResult / EnFetchResult enumerated type moves out of the original class
  10. IClient/IServer/IAgent add method:BOOL GetPendingDataLength() to get the length of the data which is not issued
  11. HPSocket4C.dll add method SendPart(),supports assigning the pointer offset parameter for data buffer
  12. add HPSocket for C# SDK(by int 2e )
  13. add HPSocket easy language support lib(by Yecate )
  14. public code package vc-common-src upgrade tp v2.3.5(reference:vc-common-src v2.3.5' Change Log)


   
> update instructions:
-----------------

  1. HP-Socket v3.2.1 Comply HP-Socket v3.1.3 and previous versions in the functions
  2. interface changes,it's needed to modify the programcode. Notice:the program can be replaced directly by v3.1.3' DLL
  3. EnServerError / EnClientError enumerated type unite into EnSocketError,notice some of the enumerated tyoe changed

==========================================================================================
v3.1.3 upgrade:
==========================================================================================

> add other language Demo:
-----------------

  1. C#
  2. Delphi
  3. E language

> Bug Fixed:
-----------------

  1. repair IP address misjudgment bug:
        1) when client component connnecting to the server,if the IP of the server has full bit(12个numbers:‘AAA.BBB.CCC.DDD’),then judged as the domain name
        2) affect component :all TCP/UDP client components
        3) affect version:v3.1.2 and all previous versions
  2. repair the domain name and host name's IP parsing error bug:
        1) when client component connecting to the server by the domain name or host name,it may be resolved to the wrong IP address.
        2) affectcomponent :all TCP/UDP client components
        3) affect versions:v3.1.2 and all previous versions

   
> update instructions:
-----------------
1、use HP-Socket v3.1.2 or previous versions for applications can upgrade to HP-Socket v3.1.3 safely

==========================================================================================
v3.1.2 upgrade:
==========================================================================================

> alter the Server component's OnClose() / OnError() event's trigger rules:
-----------------

  1. The TCP/UDP Server component of original versions,when you close a connection ,it might also fire the OnClose() event and several OnError() events
  2. for this possibility,the application need to make OnClose() / OnError() to process the event synchronously
  3. from v3.1.2 ,when there are OnClose() / OnError() events occuring together,component only notice the first event ,and ignore the left event.
  4. Therefore,when the application processes the OnClose() / OnError() event , it not need to deal with syschronization,and reduce the possibile bugs and writing or testing code burdens.

    Example One:
    --------------------------------------------------------------------------------------
    ISocketListener::EnHandleResult CServerDlg::OnClose(CONNID dwConnID)
    {
        // original versions:there are the concurrency of OnClose()/OnError(),put the code in the critical area and test the returned value

        CCriSecLock locallock(m_csPkgInfo);    // <-- critical area

        PVOID pInfo = nullptr;

        if(m_Server->GetConnectionExtra(dwConnID, &pInfo) && pInfo != nullptr)    // <-- testing the returned value
        {
            m_Server->SetConnectionExtra(dwConnID, nullptr);
            delete pInfo;
        }
    }

    Example two:
    --------------------------------------------------------------------------------------
   ISocketListener::EnHandleResult CServerDlg::OnClose(CONNID dwConnID)
    {
        // v3.1.2 version:only receive one OnClose()/OnError() event ,can remove the code out of the critical area and testing the code.

        PVOID pInfo = nullptr;
        m_Server->GetConnectionExtra(dwConnID, &pInfo);
        ASSERT(pInfo != nullptr);

        delete pInfo;
    }

> other updates :
-----------------

  1. change TCP Server default parameters :
        1) DEFAULT_SOCKET_LISTEN_QUEUE    : 300
        2) DEFAULT_ACCEPT_SOCKET_COUNT    : 300
        3) DEFAULT_FREE_SOCKETOBJ_POOL    : 150
        4) DEFAULT_FREE_SOCKETOBJ_HOLD    : 450
        5) DEFAULT_FREE_BUFFEROBJ_POOL    : 300
        6) DEFAULT_FREE_BUFFEROBJ_HOLD    : 900
  2. change  UDP Server default parameters :
       1) DEFAULT_FREE_SOCKETOBJ_POOL    : 150
        2) DEFAULT_FREE_SOCKETOBJ_HOLD    : 450
        3) DEFAULT_FREE_BUFFEROBJ_POOL    : 300
        4) DEFAULT_FREE_BUFFEROBJ_HOLD    : 900

> update instructions:
-----------------
1、 HP-Socket v3.1.1 or previous versions for applications can upgrade to HP-Socket v3.1.2 safely

==========================================================================================
v3.1.1 upgrade:
==========================================================================================

> add export the C function's dynamic link library: HPSocket4C.dll:
-----------------

  1. add the code files: HPSocket4C.h and HPSocket4C.cpp,for creating  HPSocket4C.dll
  2. export the C function and make other language(as:C/C#/Delphi etc)to use HPSocket easily
  3. HPSocket4C.dll using methods
      method one:
        --------------------------------------------------------------------------------------
            (0) (C/C++ programs)include HPSocket4C.h header files
            (1) call  ::Create_HP_XxxListener() function to create listener object
            (2) call  ::Create_HP_Xxx(pListener) function to create  HPSocket object
            (3) call  ::HP_Set_FN_Xxx_OnYyy(pListener, ...) function to set the call back function of listener
            (4) call export functions to operate HPSocket object
            (5) ...... ......
            (6) call  ::Destroy_HP_Xxx(pSocket) function to destory HPSocket object
            (7) call  ::Destroy_HP_XxxListener(pListener) functions to destory the listener object
    method two:
        --------------------------------------------------------------------------------------
            (1) the application need to use the export functions of the package to the specific language class.
            (2) after packaging encapsulated,use HPSocket in the OOP way
  4. HPSocket4C.dll dynamic link library (release version)
        (1) x86/HPSocket4C.dll        - (32bit/MBCS/Release)
        (2) x86/HPSocket4C_D.dll    - (32bit/MBCS/DeBug)
        (3) x86/HPSocket4C_U.dll    - (32bit/UNICODE/Release)
        (4) x86/HPSocket4C_UD.dll    - (32bit/UNICODE/DeBug)
        (5) x64/HPSocket4C.dll        - (64bit/MBCS/Release)
        (6) x64/HPSocket4C_D.dll    - (64bit/MBCS/DeBug)
        (7) x64/HPSocket4C_U.dll    - (64bit/UNICODE/Release)
        (8) x64/HPSocket4C_UD.dll    - (64bit/UNICODE/DeBug)

> start the Buffer Pool caching mechanism:
-----------------

  1. Common/Src adds the code file : bufferpool.h and bufferpool.cpp ,and achieve the Buffer Pool caching mechanism
  2. by the Buffer Pool caching mechanism and enhance the efficiency of memory usage,reduce the dynamic memory allocation and release operation and avoid the memory hole
  3. CTcpClient use CItemPool and TItemList to achieve transmit buffer
  4. CUdpClient use CItemPool and TItemList to achieve transmit buffer
  5. CTcpPullClient use CItemPool and TItemList to achieve transmit bufferand PULL bufferand
  6. CTcpPullServer use CBufferPool and TBuffer to achieve PULL bufferand

> other updates :
-----------------

  1. IServer adds the interface method DisconnectLongConnections() to disconnect all long connections.
  2. IServer deletes interface method GetConnectionCriSec()
  3. IClient adds methods Get/SetFreeBufferPoolSize()、Get/SetFreeBufferPoolHold() to set the size and threshold of Buffer Pool
  4. IPullServer deletes  methods  Get/SetFreePullBufferPool()、Get/SetFreePullBufferHold()
  5. HPSocket.dll and HPSocket4C.dll use /MT(d) for the options recompile,eliminate dependency on the runtime library
  6. add the TestEcho-4C testing program,show the using methods of HPSocket4C.dll

> update instructions:
-----------------

  1. HP-Socket v3.0.2 or previous versions for applications can upgrade to HP-Socket v3.1.1 safely
  2. if you want to import HPSocket4C.dll into the project , see the way of using HP-Socket,refer to the example project TestEcho-4C

==========================================================================================
v3.0.2 upgrade:
==========================================================================================

> HP-Socket complied as a dynamic link library:
-----------------

  1. applications can use the HP-Socket by the source code or importing the dynamic link library mode.
  2. dynamic link library using methods
        method one:
        -----------------------------------------------------------------------
            (0) the application contains the SocketInterface.h and HPSocket.h head files
            (1) call  HP_Create_Xxx() function to create  HPSocket object
            (2) after using the call  HP_Destroy_Xxx() function to destroy HPSocket object
        method two:
        -----------------------------------------------------------------------
            (0) the application contains the SocketInterface.h and HPSocket.h head files
            (1) create the CXxxWrapper wrapper and use the HPSocket object by the smart pointer wrapper.
  3. dynamic link library(release version)
        (1) x86/HPSocket.dll    - (32bit/MBCS/Release)
        (2) x86/HPSocket_D.dll    - (32bit/MBCS/DeBug)
        (3) x86/HPSocket_U.dll    - (32bit/UNICODE/Release)
        (4) x86/HPSocket_UD.dll    - (32bit/UNICODE/DeBug)
        (5) x64/HPSocket.dll    - (64bit/MBCS/Release)
        (6) x64/HPSocket_D.dll    - (64bit/MBCS/DeBug)
        (7) x64/HPSocket_U.dll    - (64bit/UNICODE/Release)
        (8) x64/HPSocket_UD.dll    - (64bit/UNICODE/DeBug)

> other updates :
-----------------

  1. move the component interface and the statement listener to SocketInterface.h
  2. IServer add interface methods GetConnectionCount()/GetConnectPeriod() and  each gets the number of connections and the time of connection.
  3. IServer interface methods GetListenAddress()/GetClientAddress()'s CString& change the parameter to LPTSTR
  4. IClient interface methods GetLocalAddress()'s CString& change the parameter to LPTSTR
  5. the function's CString& in SocketHelper.h change the parameter to LPTSTR
  6. the example projects: TestEcho-Pull and TestEcho-PFM use HP-Socket by importing the dynamic link library mode

> update instructions:
-----------------

  1. HP-Socket v3.0.1 or previous versions for applications can upgrade to HP-Socket v3.0.2
  2. Beacause some parameters of the interface methods have changed ,so please alter it refer to the example project.
  3. if the project want to use HP-Socket by the way of a dynamic link library,please refer to the TestEcho-Pull or TestEcho-PFM example project.

==========================================================================================
v3.0.1 upgrade:
==========================================================================================

> add UDP communication component :
-----------------

  1. add two UDP communication components :CUdpServer as the server component and CUdpClient as the client component
  2. server component  CUdpServer use IOCP communication model
  3. client component  CUdpClient use Event Select communication model
  4. UDP communication component Interface is the same of the original TCP communication component ,simple and practical
  5. UDP communication component includes communication line automatic monitoring mechanism
  6. add UDP communication component example project: TestEcho-UDP


> Code refactoring and optimization:
-----------------

  1. Specification the name of all Interface、class and code file
  2. Refactoring and optimization a lot of component code
  3. server component add the mechanism of read-write lock,effect balance deal-performance and safety
  4. server component's Socket object Cache list set locking the time,upgrade the degree of access-safety

> update instructions:
-----------------

  1. the Application of using HP-Socket v2.2.3 can safely upgrade to HP-Socket v3.0.1
  2. because of renaming a lot of Interface、class and code file ,so when system upgrading , this need to relevant change

==========================================================================================
v2.2.3 upgrade:
==========================================================================================

> the data type of connect ID change to ‘CONNID’:
-----------------

  1. in SocketHelper.h ,it defines as CONNID data type(default:typedef ULONG_PTR CONNID)
  2. Application can make  CONNID defined as it hoped type(eg:ULONG / ULONGLONG ...)
  3. order to easy to transplant and aegis,Application's everywhere should use the‘CONNID’ type quote connect ID

> server  Socket component support as every connection tie attached data:
----------------

  1. IServerSocket and CIocpServer add method  Get/SetConnectionExtra()
  2. Through the above two method ,application can make every connection tie random attached data and take it out

> other updates :
-----------------

  1. broaden CIocpServer's the limit of the number of the biggset IOCP work thread  (64 change to 500)
  2. server  Socket component's Disconnect()  method adds one marked parametric ‘bForce’,directive whether forcibly disconnect connection
  3. change connect ID's generate rule , avert generated number is 0 connection ID

==========================================================================================
v2.2.2 upgrade:
==========================================================================================

> optimization heartbeat checking's interrelated function:
-----------------

  1. IServerSocket and IClientSocket ,theirs Get/SetKeepAliveTimes()  method changes to Get/SetKeepAliveTime()
  2. CIocpServer and CClientSocket ,theirs default KeepAliveTime attribute changes to 5000
  3. CIocpServer and CClientSocket ,theirs default KeepAliveInterval attribute changes to 3000

==========================================================================================
v2.2.1 upgrade:
==========================================================================================

> Pull modelsupport :
-----------------

  1. ISocketListener add the method for the Pull model to get the data receiving notification :OnReceive(dwConnID, int)
  2. add PULL Socket Interface: IPullSocket,the interface's Fetch(dwConnID, pBuffer, iLength)  method to catch the data of communication

> Server:
-----------------

  1. server  Socket Interface: ISocketServer renamed to IServerSocket
  2. add PULL Server Socket Listrner abstract class: CPullServerSocketListener
  3. add PULL Server Socket Listrner: IPullServerSocket
  4. add PULL Server Socket Implementation class : CIocpPullServer

> Client:
-----------------

  1. client  Socket Interface: ISocketClient renamed to IClientSocket
  2. client  Socket Implementation class :CSocketClient renamed to CClientSocket
  3. add PULL Client Socket Listrner abstract class: CPullClientSocketListener
  4. add PULL Client Socket Interface: IPullClientSocket
  5. add PULL Client Socket Implementation class: CPullClientSocket

> other upgrade:
-----------------

  1. add PULL Socket testing program: TestEcho-Pull
  2. In the SocketHelper.h (.cpp) there are some structures for help.

> update instructions:
-----------------

  1. use HP-Socket v2.1.1 or previous versions for applications can upgrade to v2.2.1 safely
  2. beacause the names of  ISocketServer、ISocketClient and CSocketClient have changed,therefore,the application need to modifie the name and header file name .

==========================================================================================
v2.1.1 upgrade:
==========================================================================================

> Server:
-----------------

  1. IServerSocketListener cancel OnPrepareSocket(connID, socket) notification method
  2. IServerSocketListener alter OnAccept((connID, soClient) notification method ,add the parameter :‘soClient’,to achieve the original OnPrepareSocket(connID, socket) notification method function
  3. IServerSocketListener add OnPrepareListen(soListen) notification method ,to set the listerner to the SOCKET Options of socket
  4. ISocketServer add method  GetListenAddress(strAddress, usPort),to get the address information of the listen to Socket
  5. ISocketServer add method  GetClientAddress(connID, strAddress, usPort),for a connection of a client address.
  6. the optimization of Socket buffer pools and the managements of memory block buffer pool.
  7. change the method names for some roperty-accessings
  8. fix bugs : deadlock phenomenon may happen under special circumstances.

> Client:
-----------------

  1. ISocketServer add method  GetLocalAddress(strAddress, usPort),for get the  address information of Client Socket.
  2. Optimize the data-transmission mode , and improve the efficiency of data transmission


> other upgrade:
-----------------

  1. TestEcho and TestEcho-PFM testing program optimization
  2. in SocketHelper.h (.cpp) , there are some functions for help
  3. for SocketHelper.h ,there are the comments of all interfaces ,classes and methods defined.

==========================================================================================
v2.0.1 upgrade:
==========================================================================================

> Server
-----------------

  1. IServerSocketListener add OnPrepareSocket(connID, socket) notice the method  for set the SOCKET Options or filter client connection before using the socket
  2. ISocketServer add method  Disconnect(connID) to disconnect the client connections
  3. add IServerSocketListener' subclass CServerSocketListener,provide a default(full) notification processing method

> Client:
-----------------

  1. IClientSocketListener add OnPrepareSocket(connID, socket) notification method for set the SOCKET Options before using the socket
  2. support asynchronous Connect:ISocketServer  Start() method add one parameter (BOOL bAsyncConnect) set whether to use the asynchronous Connect
  3. add IClientSocketListener subclass: CClientSocketListener,provide default(null)notification handle methods。
  4. repair BUG:appear package loss when  its ultra-high load


> other upgrade:
-----------------

  1. support  Windows x64 platform
  2. optimzate TestEcho and TestEcho-PFM testing program.
  3. TestEcho client adds “asychronous connection” program for example.
  4. TestEcho server adds “connection filter” and “initiative disconnect ” programs for example

免责声明:文章转载自《HP-Socket v3.2.2》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇机器学习|我们在UCL找到了一个糖尿病数据集,用机器学习预测糖尿病(一)「雕爷学编程」Arduino动手做(29)——DS1302时钟模块下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

SIGPIPE信号详解

转自:http://blog.csdn.net/lmh12506/article/details/8457772 前一段面试的时候被问到项目中有没有处理SIGPIPE信号,怎么处理的?当时没有答出来,今天终于找到答案了,记录一下。 SIGPIPE信号详解 当服务器close一个连接时,若client端接着发数据。根据TCP协议的规定,会收到一个RST响应,...

linux网络编程--UNIX域套接字

UNIX域套接字   socket同样可以用于本地通信   创建套接字时使用本地协议PF_UNIX(或PF_LOCAL)PF_LOCAL   分为流式套接字和用户数据报套接字   和其他进程间通信方式相比使用方便。效率更高   用于前后台进程通信 本地地址结构:  struct sockaddr_un {   sa_family_t sun_family;...

Socket聊天逻辑

         1、A发送消息到服务器          2、服务器接收到消息后会给所有用户发送这条消息          3、如果有用户断开连接,则不用给此用户发送 一、创建持久性连接服务器  net,设置其端口号为9000 const net = require(“net”); const server = net.creatServer(); se...

websocket+probuf.原理篇

1、WebSocket     WebSocket,大家都知道,既然名字包含Socket,那么和Socket肯定差别不大,对,你没有搞错,的确差别不大。   在网络编程中,我们一般的协议都是基于TCP/IP,WebSocket也不例外。和HTTP一样,他也有自己的头部和具体的数据而已。 来看看。 这是一个,websocket发起的连接,首先一个http的请...

Visual Studio 2019使用C语言进行websocket编程

一直在写C#代码好多年不写C语言代码了,记录一下之前某个项目里用C写的一个websocket服务,用C的优势是写的东西体积小性能高,但是写业务的话还得用C#、Java之类的语言,不然会折腾死人。。。 用Visual Studio新建一个C++(因为不能直接建C语言项目)项目,我演示就创建一个控制台项目。项目创建完后首先要添加socket编程需要的依赖库ws...

WebSocket以及socketIO的使用

简介 WebSocket 使得客户端和服务器之间的数据交换变得更加简单,允许服务端主动向客户端推送数据。在 WebSocket API 中,浏览器和服务器只需要完成一次握手,两者之间就直接可以创建持久性的连接,并进行双向数据传输。 现在,很多网站为了实现推送技术,所用的技术都是 Ajax 轮询。轮询是在特定的的时间间隔(如每1秒),由浏览器对服务器发出H...