Hallo,
hab mir aus der MSDN folgenden Code abgekupfert:
1 | using System;
|
2 | using System.Collections.Generic;
|
3 | using System.ComponentModel;
|
4 | using System.Data;
|
5 | using System.Drawing;
|
6 | using System.Text;
|
7 | using System.Windows.Forms;
|
8 | using System.IO;
|
9 | using System.IO.Pipes;
|
10 | using Microsoft.Win32.SafeHandles;
|
11 | using System.Net.Sockets;
|
12 | using System.Net;
|
13 | using System.Threading;
|
14 | using System.Timers;
|
15 |
|
16 | namespace TCP_test
|
17 | {
|
18 | public partial class Form1 : Form
|
19 | {
|
20 | public Form1()
|
21 | {
|
22 | InitializeComponent();
|
23 | }
|
24 |
|
25 | private void Form1_Load(object sender, EventArgs e)
|
26 | {
|
27 |
|
28 |
|
29 | Int32 port = 3007;
|
30 | TcpClient client = new TcpClient("192.168.1.1", port);
|
31 | Byte[] data = System.Text.Encoding.ASCII.GetBytes("hallo");
|
32 | NetworkStream stream = client.GetStream();
|
33 | Console.WriteLine("Sent: {0}", "hallo");
|
34 | while (client.Connected == true)
|
35 | {
|
36 | data = new Byte[256];
|
37 | String responseData = String.Empty;
|
38 | Int32 bytes = stream.Read(data, 0, data.Length);
|
39 | responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
|
40 | Console.WriteLine("Received: {0}", responseData);
|
41 | }
|
42 | stream.Close();
|
43 | client.Close();
|
44 | }
|
45 | }
|
46 | }
|
Jetzt habe ich das Problem, dass beim Server zwar das "Hallo" ankommt,
wenn der Server dann was zurückschickt kommt das allerdings nicht an.
Kennt sich da jemand mit aus?
Grüße
Martin