<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Tutorial</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>Recent changes to Tutorial</description><atom:link href="https://sourceforge.net/p/tcpchannel/wiki/Tutorial/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 20 Dec 2012 19:35:45 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/tcpchannel/wiki/Tutorial/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Tutorial modified by Ramon Servadei</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -59,7 +59,6 @@
             public void onDataReceived(byte[] data, ITcpChannel source)
             {
                 System.out.println("Received '" + new String(data) + "' from server " + source);
-                System.exit(1);
             }

             @Override
@@ -90,5 +89,6 @@
 ~~~~~
 ...
 Connected TcpChannel [connected local=/127.0.0.1:58102 remote=localhost/127.0.0.1:12001]
+...
 Received 'Goodbye world!' from server TcpChannel [connected local=/127.0.0.1:58102 remote=localhost/127.0.0.1:12001]
 ~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ramon Servadei</dc:creator><pubDate>Thu, 20 Dec 2012 19:35:45 -0000</pubDate><guid>https://sourceforge.net2be7ad8ca238d06e9f4b7685c10a475f28449618</guid></item><item><title>WikiPage Tutorial modified by Ramon Servadei</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -13,14 +13,19 @@
     {
         new TcpServer("localhost", 12001, new IReceiver()
         {
-            
+            @Override
+            public void onChannelConnected(ITcpChannel tcpChannel)
+            {
+                System.out.println("Connected " + tcpChannel);
+            }
+
             @Override
             public void onDataReceived(byte[] data, ITcpChannel source)
             {
                 System.out.println("Received '" + new String(data) + "' from client " + source);
                 source.sendAsync("Goodbye world!".getBytes());
             }
-            
+
             @Override
             public void onChannelClosed(ITcpChannel tcpChannel)
             {
@@ -44,7 +49,12 @@
     {
         TcpChannel client = new TcpChannel("localhost", 12001, new IReceiver()
         {
-            
+            @Override
+            public void onChannelConnected(ITcpChannel tcpChannel)
+            {
+                System.out.println("Connected " + tcpChannel);
+            }
+
             @Override
             public void onDataReceived(byte[] data, ITcpChannel source)
             {
@@ -68,6 +78,8 @@

 ~~~~~
 ...
+Connected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:58102]
+...
 Received 'hello world' from client TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
 ...
 Disconnected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
@@ -76,5 +88,7 @@
   ... and the following in the client console:

 ~~~~~
-Received 'Goodbye world!' from server TcpChannel [connected local=/127.0.0.1:51838 remote=localhost/127.0.0.1:12001]
+...
+Connected TcpChannel [connected local=/127.0.0.1:58102 remote=localhost/127.0.0.1:12001]
+Received 'Goodbye world!' from server TcpChannel [connected local=/127.0.0.1:58102 remote=localhost/127.0.0.1:12001]
 ~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ramon Servadei</dc:creator><pubDate>Thu, 20 Dec 2012 19:32:59 -0000</pubDate><guid>https://sourceforge.netdb4be3d1e3e4e2546319aeffcc4ae7ccfa634cfd</guid></item><item><title>WikiPage Tutorial modified by Ramon Servadei</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -19,12 +19,6 @@
             {
                 System.out.println("Received '" + new String(data) + "' from client " + source);
                 source.sendAsync("Goodbye world!".getBytes());
-            }
-            
-            @Override
-            public void onChannelConnected(ITcpChannel tcpChannel)
-            {
-                System.out.println("Connected " + tcpChannel);
             }

             @Override
@@ -59,12 +53,6 @@
             }

             @Override
-            public void onChannelConnected(ITcpChannel tcpChannel)
-            {
-                System.out.println("Connected " + tcpChannel);
-            }
-
-            @Override
             public void onChannelClosed(ITcpChannel tcpChannel)
             {
                 System.out.println("Disconnected " + tcpChannel);
@@ -80,7 +68,6 @@

 ~~~~~
 ...
-Connected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
 Received 'hello world' from client TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
 ...
 Disconnected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
@@ -89,7 +76,5 @@
   ... and the following in the client console:

 ~~~~~
-Connected TcpChannel [connected local=/127.0.0.1:51838 remote=localhost/127.0.0.1:12001]
-...
 Received 'Goodbye world!' from server TcpChannel [connected local=/127.0.0.1:51838 remote=localhost/127.0.0.1:12001]
 ~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ramon Servadei</dc:creator><pubDate>Tue, 18 Dec 2012 14:03:24 -0000</pubDate><guid>https://sourceforge.net7ef2d80a88f37d4a3409fa254210b060c0afcc1d</guid></item><item><title>WikiPage Tutorial modified by Ramon Servadei</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>&lt;pre&gt;--- v1
+++ v2
@@ -50,17 +50,21 @@
     {
         TcpChannel client = new TcpChannel("localhost", 12001, new IReceiver()
         {
+            
+            @Override
             public void onDataReceived(byte[] data, ITcpChannel source)
             {
                 System.out.println("Received '" + new String(data) + "' from server " + source);
                 System.exit(1);
             }
 
+            @Override
             public void onChannelConnected(ITcpChannel tcpChannel)
             {
                 System.out.println("Connected " + tcpChannel);
             }
 
+            @Override
             public void onChannelClosed(ITcpChannel tcpChannel)
             {
                 System.out.println("Disconnected " + tcpChannel);
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ramon Servadei</dc:creator><pubDate>Sun, 09 Dec 2012 15:03:35 -0000</pubDate><guid>https://sourceforge.net2c35899f986ba2fc6df25465a2bb9d73f53843a4</guid></item><item><title>WikiPage Tutorial modified by Ramon Servadei</title><link>https://sourceforge.net/p/tcpchannel/wiki/Tutorial/</link><description>TcpChannel "Hello World" Tutorial
====

This tutorial will take you through all the features of TcpChannel. The tutorial requires running 2 VMs; one will host the server, the other will host the client.

This is the source code for running the server:

~~~~~
:::java
public class Server
{
    public static void main(String[] args) throws IOException
    {
        new TcpServer("localhost", 12001, new IReceiver()
        {
            
            @Override
            public void onDataReceived(byte[] data, ITcpChannel source)
            {
                System.out.println("Received '" + new String(data) + "' from client " + source);
                source.sendAsync("Goodbye world!".getBytes());
            }
            
            @Override
            public void onChannelConnected(ITcpChannel tcpChannel)
            {
                System.out.println("Connected " + tcpChannel);
            }
            
            @Override
            public void onChannelClosed(ITcpChannel tcpChannel)
            {
                System.out.println("Disconnected " + tcpChannel);
            }
        });
        System.in.read();
    }
}
~~~~~


This is the source code for the client:


~~~~~
:::java
public class Client
{
    public static void main(String[] args) throws IOException
    {
        TcpChannel client = new TcpChannel("localhost", 12001, new IReceiver()
        {
            public void onDataReceived(byte[] data, ITcpChannel source)
            {
                System.out.println("Received '" + new String(data) + "' from server " + source);
                System.exit(1);
            }

            public void onChannelConnected(ITcpChannel tcpChannel)
            {
                System.out.println("Connected " + tcpChannel);
            }

            public void onChannelClosed(ITcpChannel tcpChannel)
            {
                System.out.println("Disconnected " + tcpChannel);
            }
        });
        client.sendAsync("hello world".getBytes());
        System.in.read();
    }
}
~~~~~

After running all the two programs, you should see the following in the server console:

~~~~~
...
Connected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
Received 'hello world' from client TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
...
Disconnected TcpChannel [connected local=/127.0.0.1:12001 remote=/127.0.0.1:51838]
~~~~~

  ... and the following in the client console:

~~~~~
Connected TcpChannel [connected local=/127.0.0.1:51838 remote=localhost/127.0.0.1:12001]
...
Received 'Goodbye world!' from server TcpChannel [connected local=/127.0.0.1:51838 remote=localhost/127.0.0.1:12001]
~~~~~</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ramon Servadei</dc:creator><pubDate>Fri, 16 Nov 2012 23:31:54 -0000</pubDate><guid>https://sourceforge.netce6ddc2d5e5799e42ba3b760e9278fc5fd4ba968</guid></item></channel></rss>