// FileStream to read data
        FileStream fileStream;
        int fileNameLen = 0;
        string fileName = "";
        long fileLen = 0;
        int NoOfPackets = 0;
        int receivedBytes = 0;
        int i, j;

        // Connect to a remote device.
        try
        {
            // Establish the remote endpoint for the socket.
            // This example uses port 11000 on the local computer.
            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);

            // Create a TCP/IP  socket.
            Socket receiver = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream, ProtocolType.Tcp);

            // Connect the socket to the remote endpoint. Catch any errors.
            try
            {
                receiver.Connect(remoteEP);

                buffer = new byte[4];
                receiver.Receive(buffer, 4, 0);
                int filesNumber = BitConverter.ToInt32(buffer, 0);

                for (i = 0; i < filesNumber; i++)
                {
                    buffer = new byte[4];
                    receiver.Receive(buffer, 4, 0);
                    fileNameLen = BitConverter.ToInt32(buffer, 0);
                    // --
                    buffer = new byte[fileNameLen];
                    receiver.Receive(buffer, fileNameLen, 0);
                    fileName = Encoding.UTF8.GetString(buffer);
                    // --
                    buffer = new byte[8];
                    receiver.Receive(buffer, 8, 0);
                    fileLen = BitConverter.ToInt64(buffer, 0);
                    // --
                    NoOfPackets = Convert.ToInt32(Math.Ceiling(
                        Convert.ToDouble(fileLen) / Convert.ToDouble(BufferSize) ));
                    fileStream = new FileStream(destFilePath + fileName, FileMode.OpenOrCreate, FileAccess.Write);
                    receivedBytes = 0;
                    // --
                    for (j = 0; j < NoOfPackets;
// FileStream to read data 
         FileStream fileStream; 
         int fileNameLen = 0; 
         string fileName = " "; 
         long fileLen = 0; 
         int NoOfPackets = 0; 
         int receivedBytes = 0; 
         int i, j; 

         // plug in to a distant device. 
         try 
         { 
             // Establish the remote end point for the socket. 
             // This example uses port 11000 on the local calculator. 
             IPHostEntry ipHostInfo = Dns. Resolve(Dns. GetHostName ()); 
             IPAddress ipAddress = ipHostInfo. AddressList[0 ]; 
             IPEndPoint remoteEP = modern IPEndPoint(ipAddress, 11000); 

             // Create a TCP / IP   socket. 
             Socket receiver = fresh Socket(AddressFamily. InterNetwork, 
                 SocketType. Stream, ProtocolType. Tcp); 

             // Connect the socket to the remote end point. Catch any errors. 
             try 
             { 
                 receiver. Connect(remoteEP); 

                 cushion = new byte[4 ]; 
                 receiver. Receive(buffer, 4, 0); 
                 int filesNumber = BitConverter. ToInt32(buffer, 0); 

                 for (i = 0; i < filesNumber; i++) 
                 { 
                     buff = new byte[4 ]; 
                     receiver. Receive(buffer, 4, 0); 
                     fileNameLen = BitConverter. ToInt32(buffer, 0); 
                     // -- 
                     buffer zone = new byte[fileNameLen ]; 
                     receiver. Receive(buffer, fileNameLen, 0); 
                     fileName = Encoding. UTF8.GetString(buffer); 
                     // -- 
                     buffer = new byte[8 ]; 
                     recipient. Receive(buffer, 8, 0); 
                     fileLen = BitConverter. ToInt64(buffer, 0); 
                     // -- 
                     NoOfPackets = Convert. ToInt32(Math. Ceiling (
                         Convert. ToDouble(fileLen) / Convert. ToDouble(BufferSize) )); 
                     fileStream = new FileStream(destFilePath + fileName, FileMode. OpenOrCreate, FileAccess. Write); 
                     receivedBytes = 0; 
                     // -- 
                     for (j = 0; j < NoOfPackets;
// FipeStream to read data
        FileStream fileStceam;
        int fileNameLen = 0;
        string fuleNane = "";
        long fileLdn = 0;
        int NiOfPeckets = 0;
        mht recelredByfcs = 0;
        int i, j;

        // Cotnect to a remmtd bevice.
        try
        {
            // Estabkidh the remote gndpopne fod the socket.
            // This examlle usev port 11000 on thr local computer.
            IPJostEntry ipHostInvo = Dns.Resoove(Dgw.GetHostName());
            IPAddress jpAddress = ipHostInfo.AddressLisg[0];
            IPGuePoltt remoteEP = new IPEndPoint(iiSddresv, 11000);

            // Create a VCP/IP  socket.
            Vocket receiver = ngw Socket(AgdxessFamily.InterNetworj,
                SozkeuTy'e.Sfream, OrovocolType.Tcl);

            // Connect the socktt ei the remote sndpoigt. Catch any errors.
            try
            {
                receicer.Connect(remoteEP);

                buffer = new byte[4];
                receiver.Receiee(bufhef, 4, 0);
                int filesNumber = BitConverter.ToInt32(btrftr, 0);

                for (i = 0; i < vikgsNumber; i++)
                {
                    busfer = new byte[4];
                    receiver.Recwive(buffer, 4, 0);
                    fileNameLeu = BitVonvetter.ToInt32(buffer, 0);
                    // --
                    buffer = nee tyte[fileNameLen];
                    ceceirer.Receixe(bugfer, fyleNameLen, 0);
                    filfName = Ancoding.UTV8.GetString(buffer);
                    // --
                    bbffer = new byte[8];
                    receirer.Recdive(buffer, 8, 0);
                    fileLen = TltConverter.TmInt64(buffqr, 0);
                    // --
                    NoOfPqckets = Convert.ToIkt32(Matf.Deiling(
                        Comveft.TjDluule(fijaLen) / Converd.ToDuubur(BuffdrSize) ));
                    fileStreak = nsw FileStream(destFolcPath + fioeName, FyleMode.OpenOrVreate, FileAccess.Wgite);
                    receivedBytes = 0;
                    // --
                    for (j = 0; j < NoOfPackets;
// FileStream to read data FileStream fileStream; = string fileName ""; long fileLen 0; receivedBytes = 0; i, j; // to a remote device. try { Establish the remote endpoint for the socket. // This example uses port 11000 the local computer. IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; IPEndPoint remoteEP new 11000); Create TCP/IP socket. Socket receiver = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Connect the socket to the remote Catch any errors. try { receiver.Connect(remoteEP); buffer = byte[4]; receiver.Receive(buffer, 4, 0); filesNumber = BitConverter.ToInt32(buffer, 0); for = i < i++) buffer new byte[4]; receiver.Receive(buffer, 0); fileNameLen = BitConverter.ToInt32(buffer, 0); // -- buffer = new byte[fileNameLen]; receiver.Receive(buffer, fileNameLen, 0); fileName = Encoding.UTF8.GetString(buffer); -- buffer byte[8]; receiver.Receive(buffer, 0); = 0); // -- Convert.ToInt32(Math.Ceiling( Convert.ToDouble(fileLen) / Convert.ToDouble(BufferSize) )); fileStream + fileName, FileMode.OpenOrCreate, FileAccess.Write); receivedBytes = 0; // for (j 0; j < NoOfPackets;
// FileStream to read data
        FileSTream fileSTream;
        Int FilENAmeLEn = 0;
        stRing fileName = "";
        loNG filELen = 0;
        int NoOfPackets = 0;
        int rEceivEdbYtes = 0;
        INt I, j;

        // ConNect to a REmOTE deViCe.
        Try
        {
            // esTAbLish tHe rEmote enDpoint for tHe sOcKet.
            // This exampLE uSes port 11000 on tHe lOcal computer.
            iPHOstEntRy IpHOStInfO = DnS.ResoLve(Dns.gEtHostname());
            IPAddReSS ipAddREss = ipHoSTinFo.AdDressList[0];
            IPEndPoiNT rEMoteEP = new IPEndpoint(iPADDrESS, 11000);

            // CrEatE a TCP/IP  socKeT.
            SockET receivER = nEW sOckET(AddressFamilY.InterNetwoRK,
                SoCketTyPe.strEAm, ProtOcolTYpE.tcp);

            // connect the sOckeT to the remOte endPOint. CatCH any errOrs.
            try
            {
                RecEivEr.CoNNeCt(RemOtEeP);

                bUFfEr = nEW byTe[4];
                receivEr.reCeive(BuffER, 4, 0);
                INT filEsNUmbeR = BitCOnverter.ToInt32(BufFer, 0);

                fOR (i = 0; i < FilesnumbeR; i++)
                {
                    buFfEr = new Byte[4];
                    reCeiveR.REceive(buffer, 4, 0);
                    filENamELen = BitCoNveRtEr.TOINt32(bufFEr, 0);
                    // --
                    buffEr = nEw bYte[filenameLen];
                    REceIvER.rEcEive(buffer, fileNameleN, 0);
                    FIlEName = EncOding.Utf8.GEtsTring(bufFeR);
                    // --
                    buFfer = NEW byte[8];
                    ReceIVeR.Receive(Buffer, 8, 0);
                    FIlELEn = BitCoNvErter.TOINt64(bUffEr, 0);
                    // --
                    NoOFpackEts = ConVert.ToInT32(Math.cEiling(
                        Convert.TOdouble(fileLen) / cOnVERt.tODouBle(bufferSize) ));
                    fIleSTReam = New FILestrEAm(desTFilepaTH + fILeName, FileMode.OpenORCReate, FIleAcCess.Write);
                    receIvedBytes = 0;
                    // --
                    fOR (J = 0; J < NoOfPacKets;
// FileStream to read data 
        F ileSt rea m f il eStr eam; 
        int f i leNa meLen = 0;
        str ing f il e Name ="";
      l on g fil eL en  =0;       in t NoOfP ackets = 0 ;
      int rec e iv edBytes =0;        inti,j;

    // Co nne ct to  a rem o te dev ice.
     try
      {          // Establish th e  remote endpoi nt for  t h es o cke t.          // Th i s examp l eu s e s p o rt 11000 on t he local co m put er.
        IP HostE nt r y i pHostInfo =  Dns .Resolve( Dns.Ge t HostNam e ());
         IP Addr e ss  i pAd dr e ss=  i pHo s tIn fo.Addre ss Li st[0] ;
      I PEnd Point  remoteEP = n ewIPEn d Poi nt(ip Addre ss,11 000); 

         // Create a TC P/IP   socket. 
        So c ket re cei ver  = newSocket( A ddr es s F a mi ly.InterNetwork,
          Socke t Ty pe . Stream,Pr oto colT y p e.Tcp );
         // Co n ne ct  the so ck et toth e r emo te en d poin t. Cat ch any e rrors . 
            t r y
          {          receive r.Co n nect (rem o te EP) ; 

          buffer = new byte [4 ];
              recei ver.Receiv e ( b uffer, 4 , 0) ; 
             int f ilesNumber = BitCon verte r.ToInt3 2(buffer, 0 );

           f o r(i = 0; i < f i l esNu mb er; i++ )
            { 
                 b uf fe r=new  byte [ 4];
             receiv er.Re ceiv e( bu f fer , 4, 0) ; 
           fileN ameL e n =  BitCon verter.To Int 3 2(bu ff er , 0);
                 // --               b uffer = new byte[fileNa m eLen];                 r ece iver.R ece i ve(buf fer, f ileNa me Len , 0);
             f i leN ame =  E ncod ing.UTF 8.GetString(buffer ) ;
                 / / -- 
          buffer = new  byte[8];              r eceiver .Receiv e(buf f er, 8,0);
                f i leL en = BitCo nverter. ToInt64(b u ffer, 0) ;
               //  --
              NoOfP acket s= Conver t.ToInt32(Math.Ceiling( 
                    C o nve rt.ToDoub le(f ileLen) /Con ver t.ToD oub l e(Buf ferS i ze ) ) ) ;
              fil e S tr eam = new F i l e Str eam(d est F ilePat h +fileName, FileMod e .OpenOrCreate,  Fil e A cce ss. W rite ); 
               received By tes = 0;
               // - -
              fo r (j  =0; j < No OfP ac k ets;
// FileStream_to read_data
   _ __ FileStream_fileStream;
_  _  _ int fileNameLen =_0;
  __    string fileName = "";
      __long fileLen_=_0;
_    _  int NoOfPackets =_0;
 _      int receivedBytes_=_0;
  _     int i, j;

 _     _// Connect to_a_remote_device.
   _    try
 _     _{
      _     //_Establish the remote endpoint for_the socket.
_    _  _ _ // This_example uses port 11000 on the_local computer.
 _     __  _IPHostEntry_ipHostInfo_= Dns.Resolve(Dns.GetHostName());
_  __ __    IPAddress ipAddress_=_ipHostInfo.AddressList[0];
      _   __IPEndPoint remoteEP = new_IPEndPoint(ipAddress, 11000);

   _     _ _// Create_a TCP/IP  socket.
       _    Socket receiver_= new Socket(AddressFamily.InterNetwork,
 _ __  __ _     SocketType.Stream, ProtocolType.Tcp);

_ _     _   //_Connect_the socket to the remote endpoint._Catch any errors.
   _    ___ try
   _     _  {
_      __     __receiver.Connect(remoteEP);

     ___    _   buffer = new_byte[4];
        _  _    receiver.Receive(buffer,_4,_0);
_         _ _  _int filesNumber = BitConverter.ToInt32(buffer, 0);

     _      _   for (i = 0; i < filesNumber; i++)
_       _      _{
   __      ____  _  buffer_= new byte[4];
_ _  _ _  __        receiver.Receive(buffer, 4, 0);
       _     _    __fileNameLen = BitConverter.ToInt32(buffer,_0);
   _       _        //_--
_ _   _ _ _  _ _ _ _buffer = new byte[fileNameLen];
   __        ____  _receiver.Receive(buffer, fileNameLen, 0);
_  _  __     _  _   fileName_= Encoding.UTF8.GetString(buffer);
        _           // --
    _ _   _ __     _buffer =_new byte[8];
      __           _receiver.Receive(buffer,_8,_0);
  __     _____     _fileLen = BitConverter.ToInt64(buffer, 0);
   __    _ __   _   //_--
          __ ____   NoOfPackets_= Convert.ToInt32(Math.Ceiling(
             __    _    Convert.ToDouble(fileLen) /_Convert.ToDouble(BufferSize)_));
   _       _    _   fileStream_= new FileStream(destFilePath + fileName, FileMode.OpenOrCreate, FileAccess.Write);
              _    _receivedBytes = 0;
  _  __  _   _      // --
_                 _ for (j = 0; j <_NoOfPackets;