DSIK_FILEZILLA/sikFtpClient/Connection/Connection.cs
2019-01-21 20:06:33 +01:00

46 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace sikFtpClient.Connection
{
abstract class Connection
{
public int port { get; set; }
public string server { get; set; }
public TcpClient client { get; set; }
public NetworkStream stream { get; set; }
protected string receiveData(NetworkStream stream)
{
Byte[] data = new byte[1024];
string responseData = string.Empty;
int bytes = stream.Read(data, 0, data.Length);
//read TcpServer response
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
return responseData;
}
protected void sendData(NetworkStream stream, Byte[] data)
{
//send message to TcpServer
stream.Write(data, 0, data.Length);
}
protected static Byte[] textToBytes(string text)
{
return System.Text.Encoding.ASCII.GetBytes(text);
}
}
}