Bonjour à tous,
J'essay de créer une connection entre mon émulateur windows phone et un programme C++ qui écoute sur le port 3000 via une socket serveur.
J'ai cependant toujours la même erreur qui apparaît :
Voici le code de ma mainPage qui utilise la socket et qui tente d'ouvrir un connection ,A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.dll
et Voici le code de ma classe SocketClient ,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 SocketClient socketclient = new SocketClient(); socketclient.CreateConnection("127.0.0.1", 3000);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public class SocketClient { private Socket connection; private string server; private int serverPort; public event EventHandler<CreateConnectionAsyncArgs> CreateConnectionCompleted; public void CreateConnection(string serverAddress, int port) { this.connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.server = serverAddress; this.serverPort = port; var connectionOperation = new SocketAsyncEventArgs { RemoteEndPoint = new IPEndPoint(IPAddress.Parse(this.server), this.serverPort) }; connectionOperation.Completed += OnConnectionToServerCompleted; this.connection.ConnectAsync(connectionOperation); } private void OnConnectionToServerCompleted(object sender, SocketAsyncEventArgs e) { if (e.SocketError != SocketError.Success) { if (CreateConnectionCompleted != null) CreateConnectionCompleted(this, new CreateConnectionAsyncArgs(false)); return; } if (CreateConnectionCompleted != null) CreateConnectionCompleted(this, new CreateConnectionAsyncArgs(true)); } public void Close() { if (connection != null) { connection.Close(); } } } public class CreateConnectionAsyncArgs : EventArgs { public bool ConnectionOk { get; private set; } public CreateConnectionAsyncArgs(bool connectionOk) { ConnectionOk = connectionOk; } }
Merci beaucoup pour votre aide.
Cordialement,
Ludovic.
Partager