// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net.Sockets; using System.Text; namespace E { public class Client { public static void Main(string[] args) { TcpClient cli = new TcpClient("localhost", 1234); Stream stm = cli.GetStream(); string filename = @"C:\foobar.txt"; byte[] data = { 1, 2, 3, 4, 5 }; int lenfilename = Encoding.Default.GetByteCount(filename); stm.WriteByte((byte)lenfilename); stm.Write(Encoding.Default.GetBytes(filename), 0, lenfilename); stm.Write(data, 0 , data.Length); stm.Close(); cli.Close(); } } }