Ioserver open source project introduction and source code analysis

Source: Internet
Author: User

Ioserver is a lightweight Server framework that imitates Mina. Recently, due to the use of Mina, I have read the source code of ioserver. By the way, I am familiar with j2se NiO.

 

Ioserver is designed to be a mobile online game server framework. TCP protocol is supported.

 

The usage of this framework is similar to that of Mina. It has a protocolhandler and iohandler without Mina's filterchain;

 

The basic process is to create a config, set the port, protocolhandler, and iohandler, and start the server. Very convenient.

 

Ioserver defines a netmessage class that requires all service classes to implement this interface.

 

Ioserver has three core classes: ioserviceimpl, ioreadwritemachine, and iosession;

 

Ioserviceimpl uses NiO to poll serversocket. When there is a new connection on the server port, it receives the connection and creates an iosession;

 

Ioreadwritemachine uses NiO to poll the client socket of the machine. When a socket has data, it calls the corresponding iosession to read the parsing data. When a socket has data to be sent, call the sending method of the corresponding iosession;

 

Iosession: Read data and call protocolhandler and iohandler to process the data. When there is data in the cache queue to be sent, send it.

 

Note:

Relationship between ioserviceimpl and ioreadwritemachine:

 

Ioserviceimpl is only responsible for processing server ports;

 

Ioreadwritemachine is managed by ioreadwritemachinemanager. There are several CPUs, just several ioreadwritemachine, And the iosession is evenly allocated to each CPU.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.