2. Connector entfernt

This commit is contained in:
2014-04-03 10:43:49 +02:00
parent 46b820f2b6
commit 5db78d7581
3 changed files with 0 additions and 93 deletions

View File

@@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Connector
{
class Program
{
static void connect()
{
Thread t1, t2;
Receiver receiver = new Receiver();
Sender sender = new Sender();
String message = Console.ReadLine();
t1 = new Thread(() => receiver.receive());
t2 = new Thread(() => sender.send(message));
t1.Start();
t2.Start();
}
static void Main(string[] args)
{
connect();
}
}
}

View File

@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Connector
{
class Receiver
{
Int32 port = 80;
private TcpClient client;
private NetworkStream inStream;
Byte[] data;
public void receive()
{
client = new TcpClient("localhost", port);
inStream = client.GetStream();
data = new Byte[256];
String responseData = String.Empty;
Int32 bytes = inStream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
inStream.Close();
client.Close();
}
}
}

View File

@@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Connector
{
class Sender
{
Int32 port = 80;
private TcpClient client;
private NetworkStream outStream;
Byte[] data;
// ASCIIEncoding encoder;
// byte[] buffer;
public void send(string message)
{
//buffer = encoder.GetBytes(message);
client = new TcpClient("localhost", port);
data = System.Text.Encoding.ASCII.GetBytes(message);
outStream = client.GetStream();
//message = Console.ReadLine();
outStream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", message);
outStream.Close();
client.Close();
}
}
}