ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
852
852
EMPFEHLEN
-
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/e...-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 :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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 :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
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:
Vielleicht werdet ihr schlauer daraus. Danke im VorausSocketException 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
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
.
Ich komme bald für andere interessante Fragen :P
Gruß, Florence
Ähnliche Themen
-
.NET Compact Framework 2.0 Problem
Von reuchlein im Forum .NET CaféAntworten: 2Letzter Beitrag: 02.10.09, 17:23 -
.NET Compact Framework 3.5
Von Mexxchen im Forum .NET CaféAntworten: 0Letzter Beitrag: 16.11.08, 22:45 -
Compact Framework & Threads
Von realbora im Forum .NET CaféAntworten: 1Letzter Beitrag: 21.11.07, 17:03 -
Compact Framework und Kryptographie
Von MD1978 im Forum .NET ArchivAntworten: 1Letzter Beitrag: 15.12.04, 10:05 -
Compact Framework und Serialisieren
Von manschi im Forum .NET ArchivAntworten: 3Letzter Beitrag: 14.12.04, 09:16





Zitieren
Login





