Übungsblatt 2: Hier mal ein Ansatz

This commit is contained in:
Samed Bektas
2014-03-23 17:23:48 +01:00
parent 7b6a12be00
commit da8fba72b9
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
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
{
private TcpClient client;
private NetworkStream inStream;
public void receive()
{
client = new TcpClient("localhost", 80);
inStream = client.GetStream();
}
}
}

View File

@@ -0,0 +1,29 @@
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
{
private TcpClient client;
private NetworkStream outStream;
ASCIIEncoding encoder;
byte[] buffer;
public void send(string message)
{
buffer = encoder.GetBytes(message);
client = new TcpClient("localhost", 80);
outStream = client.GetStream();
message = Console.ReadLine();
outStream.Write(buffer, 0, buffer.Length);
outStream.Flush();
client.Close();
}
}
}