ファイルとノミで処理した後、ほとんど何も判明しませんでした (:
Meet-バギーチャンネル経由でデータを送信するためのSyncStreamライブラリ:
- 一部のデータが途中で「失敗」した場合、サーバーとクライアント間の同期を復元します
- 提供されたすべてのパッケージの整合性をチェックします。
- 重要なパッケージのための保証された配信メカニズムを備えています
- 基礎となる伝送プロトコルに縛られていない- レーザーチャンネルにねじ込むことさえ可能
UPD:明らかに、チャネルがツイストペアとTCP / IPだけではないことは明らかではありません。 このライブラリは、一般的に、トランスポート(無線チャネルまたは赤外線ポート)に関係なく、インターフェイスクラスを記述して取得するだけで動作します。
UPD 2:Persistentの場合:ライブラリはTCP / IPに関連付けられていません
仕事の原理について
ソケットを作成するときにマルチプロトコルを実装するには、ソケット固有のConnect()、Close()、Bind()、Listen()、Send()、Receive()メソッドを含むBaseImplementation抽象クラスから派生したクラスを渡します。 その後、データの送信に直接関連するすべてのアクションは、このクラスを介して実行されます。
TCPを介した作業に対応するクラスは、すでにライブラリに含まれています。
データはパケットとして送信されます 。
パッケージに含まれるもの:
- パッケージの始まりのマジックシーケンス
- パッケージ長
- チェックサム
- パッケージの種類
- チーム名
- 引数リスト:
- 引数名
- 値(string / int / byte [])
- パッケージの終わりのマジックシーケンス
「余分な」データがチャネルに入るか、データの一部が失われたときに、次のパケットの開始を見つけるために「マジックシーケンス」が必要です(同期を復元します)。
楽しく楽しい使用について
クライアントコードの例:
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
Copy Source | Copy HTML class MainClass { public static void Main( string [] args) { Socket s = new Socket ( new TcpImplementation ()); s.Receive += new Socket . ReceiveEvent (OnReceive); s.Connect( "127.0.0.1:1111" ); while ( true ) { string ss = Console .ReadLine(); Packet p = new Packet ( "message" , new Argument ( "text" , ss)); p.Important = true ; s.Send(p); } } public static void OnReceive( Socket s, Packet p) { Console .WriteLine( "<< " + p[ "text" ]); } }
ライブラリとソースをダウンロードできます。また、クライアントとサーバーのより複雑な例もここで見つけることができます。
GitHubリポジトリ
ZIPダイレクトリンク