Socket-based asynchronous communication system written in C #--sanniusignal.dll Open source

Source: Internet
Author: User

Since the launch of the SanNiuSignal.DLL, the user is still full of good feedback, in order to better serve the people, I have fixed a lot of bugs, while the DLL open source, the following first introduced

A simple communication system developed using this DLL:

Which module you want to use to start which module, you can form communication with the customer; specific source 1:http://www.sanniub.com/down/html/?6.html Baidu network disk: Http://pan.baidu.com/s/1i346GML It contains the source code of SanNiuSignal.DLL and one of its use examples; please add QQ group: 426414437 Exchange, update later

DLL was released in the group .... Here is a detailed description of the source code for SanNiuSignal.DLL

Sanniusignal is a completely free DLL based on an asynchronous socket, which encapsulates the client,server and UDP; With this DLL, the user does not care about the heartbeat; sticky bag
, package, send files and other tedious things, everyone just a few steps to achieve a strong communication system, can help everyone is I feel the most happy things, but also hope that everyone
In the process of using to find out the shortcomings of the DLL; good correction; the apple and Java editions of this DLL are working hard to develop ...

Here's a look at how to use sanniusignal.

1): TCPServer server, Txstart.startserver register successful server Itxserver through static method, then set various properties through Itxserver;
Itxserver.startengine (); You can go to the demo, it's relatively simple, here's where to look.
One: Itxserver.buffersize, is to receive the data buffer size, the default is 1KB, not less than 50 bytes, and the client is set to the same;
The size of this buffer does not affect the size of each data you send, and the size can only increase your sending speed.
Two: Itxserver.sendmessage before sending to determine whether this IPEndPoint client is online, because if not in line, etc., this method does not have any messages;
Sent successfully and the other party has received;
Third: The user can record the operation information of the server through Itxserver.filelog;

2): TcpClient client, register successful client Itxclient through static method Txstart.startclient (server address or URL, server port number);
Itxclient set the various properties, and finally start the Itxclient.startengine (), and the server to start the same, the specific can be seen in the demo; The client should pay attention to some of the
Party
A: If the non-server forced to shut down the client case, the client will be re-connected by default; and his principle is this, re-connect every 10 seconds; re-connect
Itxclient.reconnectmax the client engine is automatically shut down if it fails; you can change the IP address and port number of the client connection server;
If you do not want to re-connect when disconnecting, you can set itxclient.reconnectmax=0;
Second: Log in, before the engine starts, the user can set the Itxclient.outtime to set the time-out period, the default is 10 seconds, that is, within 10 seconds will have a login result
; Login succeeded or login failed. Login results can be triggered by login results;

3): UDP engine, through static method TXSTART.STARTUDP () registration successful udp--iudptx, and then through Iudptx set various properties;
Iudptx.startengine (); If you want to bind the port number before starting it, set iudptx.port here, or use the local port randomly, whether it is UDP or server and
Clients, many of their methods and properties and events are the same because they inherit the communication system's base interface Itxbase; Here's what the UDP engine should be aware of.
One: The advantage of UDP is fast but not too reliable, so some properties can not be set too, such as iudptx.buffersize; default is 1KB, if you send information on the WAN,
The buffer size should not exceed the default value, otherwise the data will be lost, if the one-time data is greater than 1KB, it is OK, the system will automatically send packets;

4): File sending system, generate a file sending system Ifilesend by static method Filestart.startfilesend (Ifilesendmust); Ifilesendmust is
An interface that must be implemented, a specific reference to the demo, and then the various properties are set through the Ifilesend, sent or sent through the previous three engine systems;
Itxclient.sendfile This will return a file tag, which is an integer; ifilesend can manipulate the file that is being sent by manipulating the tag; receive file
The system is also the same, also through the file tag to operate, file continuation is the same, but also through the previous three communication engine system to continue transmission; Because the file system does not determine the user
The communication system through which the continuation of the transmission, for example, iudptx.continuefile to continue; You can also try to drop the line after the reconnection can also be continued;

5): File receiving system, through static method Filestart.startfilereceive (ifilereceivemust) generate a file receiving system ifilereceive;
Ifilereceivemust is an interface that must be implemented by the receiver, refer to the demo, and then set the various properties through ifilereceive; The file system should be noted below
A few points
One: Each file has a file label, the sending system and the receiving system is controlled by this tag to control the file, if the same file transfer, the same label;
Two: To note that the property buffersize buffer size, he is the number of bytes transmitted at a time, if the file buffer larger, the faster the transfer speed;
home to debug; TCP transmission can generally be set to a relatively large, but the UDP words do not exceed 1KB, so the transmission of large files as far as possible not to use UDP this unreliable stuff;
Third: When the network and other reasons for the interruption of the file, the file interrupt event will be triggered, the file is automatically suspended send or receive status, waiting for the continuation of the transmission, the sender, if the other party
Consent to the continuation of the transmission, the other party will not trigger the beginning of the method of continuation, other people can be found through the demo;


Summarize:
In fact, this DLL is relatively simple, as long as you master these five interfaces; 1:itxserver TCP Server Interface 2:itxclient TCP Client interface 3:iudptx
UDP interface 4:ifilesend file Sender interface 5:ifilereceive file receiver interface Front three interfaces are initiated via Txstart; back two file interfaces
is started by Filestart.

Let's talk about it here today, hope this DLL is helpful to everyone, the lack of hope through the QQ or blog park to communicate with you;

This demo Source: Http://pan.baidu.com/s/1i346GML inside includes the SanNiuSignal.DLL

Socket-based asynchronous communication system written in C #--sanniusignal.dll Open source

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.