TCP/IP Verbindung mit Windows CE 6.0 Gerät und .net Compact Framework

florad

Grünschnabel
Hallo Tutorialer,
ich bin neu auf diesem Forum und hoffe, dass mir geholfen wird. Hab schon im Internet gesucht und finde leider keine Lösung zu meinem Problem.
Im Rahmen meiner Abschlussarbeit muss ich eine TCP/IP Kommunikation zw. meinem Rechner und einem WinCE Gerät aufbauen.
So sieht das gerät aus: http://www.keith-koep.com/produkte/evaluationkit/evaluationkit-pxa270-wireless.html
In der Verbindung muss das Board mal als Server mal als Client agieren. Als Client funktioniert es prima. Mit dem Server habe ich Schwierigkeiten. Mein Rechner kann einfach nicht mit dem kommunizieren:
Hier die Codes, sind in C# geschrieben:

Server:
Code:
private void verbindeMitClient()
        {
int port = 2000;
            try{
           Socket listeningSocket = new Socket(AddressFamily.InterNetwork,
                    SocketType.Stream,
                    ProtocolType.Tcp);
                IPAddress ipAddress = IPAddress.Parse(dottedServerIPAddress);
                IPEndPoint edp = new IPEndPoint(IPAddress.Any, port);
                Console.WriteLine("Listening for the client..."+edp.Address.ToString()+":"+edp.Port);
                listeningSocket.Bind(edp);
                listeningSocket.Listen(1);
               Socket communicationSocket = listeningSocket.Accept();     
                    //wait infinitely to get a response
                    byte[] inBuffer = new byte[1000];
                    if (communicationSocket.Connected)
                    {
                        Console.WriteLine("Connected to client.");
                        int count = communicationSocket.Receive(inBuffer);
                    }
                    else {
                        Console.WriteLine("keine Verbindung möglich");
                    }
                    string message = new string(Encoding.UTF8.GetChars(inBuffer));
                    Console.WriteLine("Received '" + message + "'.");
            
            }catch(SocketException se){

                Console.WriteLine("SocketException\n\n");
            }

            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            //throw new Exception("The method or operation is not implemented.");
        }

Client:
Code:
namespace ComputerClient
{
    class Program
    {
        private static string dottedServerIPAddress = "192.168.55.101";
        private static int port = 2000;
        static void Main(string[] args)
        {
            try {
                
            
            
            using (Socket clientSocket = new Socket(AddressFamily.InterNetwork,
                    SocketType.Stream,
                    ProtocolType.Tcp))
            {
                // Addressing
                IPAddress ipAddress = IPAddress.Parse(dottedServerIPAddress);
                IPEndPoint serverEndPoint = new IPEndPoint((ipAddress, port);
                // Connecting
                Console.WriteLine("Connecting to server " + serverEndPoint);
                try
                {
                    clientSocket.Connect(serverEndPoint);
                }
                catch (SocketException se) { Console.WriteLine(se.ToString()); }
                if(clientSocket.Connected)
                Console.WriteLine("Connected to server.");
                else Console.WriteLine("Server konnte nicht erreicht werden.");
                // Sending
                byte[] messageBytes = Encoding.UTF8.GetBytes("Hello World!");
                clientSocket.Send(messageBytes);
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }// the socket will be closed here
        }
        catch (System.Security.SecurityException se)
        {
            Console.WriteLine(se.StackTrace.ToString());
        }
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
        }
    }

Der Client(also mein Computer ) schafft das einfach nicht die IPAdresse des Boards zu finden. Wieso weiß ich nicht. Ich bekomme immer so einen Fehler:
SocketException was unhandled: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
Vielleicht werdet ihr schlauer daraus. Danke im Voraus

Gruß, Florence
 
hab selber die Lösung gefunden: Die LAN Schnittstelle auf dem Gerät hat nicht funktioniert, ist nur zum Schein da :). Wlan hat funltioniert. War aber zu schwach um eine Verbindung im Internet herstellen zu können. Hat aber irgendwann wo anderss funktioniert :D.
Ich komme bald für andere interessante Fragen :p

Gruß, Florence
 
Zurück