Übungsblatt 2: Hier mal ein Ansatz
This commit is contained in:
22
Connector/Connector/Receiver.cs
Normal file
22
Connector/Connector/Receiver.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Connector/Connector/Sender.cs
Normal file
29
Connector/Connector/Sender.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user