OK to Ask for programming help?

First of all a HAPPY Thanksgiving to ALL!

Guess I’m not smart enought to pull it off. I have tried many different ways (none worked).

I want to have a text exchange (sort of a chat application) between my Fez.Spider and my Android Tablet. I have been able to by using a Bluetooth connection but I want to do it using a "Socket’. I have a small application (attached) that works but it is a ‘TcpClient’ using .NET Framework 4 Client Profile (A Console Application).

What I need is an equivalent using GHI’s .Net Micro Framework 4.2

Anyone care to help this old man??

The following Console application works well for my needs but is not .Net Micro Framework 4.2



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;

// This app.. .NET Framework 4 Client Profile (A Console Application)

namespace ClientExample
{
    class Program
    {
        const string SERVER_IP = "192.168.2.6";
        const int SERVER_PORT = 8080;

        static void Main(string[] args)
        {
            TcpClient client = new TcpClient();
            Console.Write("Connecting... ");

            client.Connect(SERVER_IP, SERVER_PORT);
            Console.WriteLine("Connected\n");

            using (Stream stream = client.GetStream())
            {
                while (true)
                {
                    Console.WriteLine("Enter a string and press ENTER");
                    Console.WriteLine("OR only press ENTER to exit");
                    Console.WriteLine();

                    string message = Console.ReadLine();
                    if (string.IsNullOrEmpty(message))
                        break;

                    byte[] data = Encoding.UTF8.GetBytes(message);
                    Console.WriteLine("Sending... ");

                    stream.Write(data, 0, data.Length);

                    byte[] response = new byte[128];
                    int bytesRead = stream.Read(response, 0, response.Length);

                    /*
                     * Android using Prefix... first byte is length, then 3 bytes of 0's, then the data bytes
                     * Android without using Prefix... Returns only data bytes
                      
                       AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
	    AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
                    */
                    Console.WriteLine("Response: " + Encoding.Default.GetString(response, 0, bytesRead));
                    Console.WriteLine();
                }
            }
            client.Close();
        }

    } //End class
} //End namespace
//


@ willgeorge - I don’t believe there is anything equivalent to a web socket in NETMF 4.2. You’ll have to roll your own. There are plenty of sample web servers & clients on Codeshare to get you started. I look forward to seeing your implementation of web sockets added :slight_smile: