_family = AF_INET;
    addr.sin_port = htons(portNumber);
    bind(Socket, (sockaddr*) &addr, sizeof(Addr));

    if (listen(Socket, 1) == SOCKET_ERROR) {
        printf("Listening error!\n");
    } else {
        printf("Listening...\n");
    }

    if (Sub = accept(Socket, (sockaddr*) &incomingAddress, &AddressLen)) {
        char *ClientIP = inet_ntoa(incomingAddress.sin_addr);
        int ClientPort = ntohs(incomingAddress.sin_port);
        printf("Client connected!\n");
        printf("IP: %s:%d\n", ClientIP, ClientPort);

        printf("Sending file... \n");

        FILE *File;
        char *Buffer;
        unsigned long Size;

        File = fopen("test.txt", "rb+");
        if (!File) {
            printf("Error while reading the file!\n");
            getchar();
            return 0;
        }

        fseek(File, 0, SEEK_END);
        Size = ftell(File);
        fseek(File, 0, SEEK_SET);

        Buffer = malloc(Size);

        fread(Buffer, Size, 1, File);
        char cSize[MAX_PATH];
        sprintf(cSize, "%i", Size);

        fclose(File);
        send(Sub, cSize, MAX_PATH, 0); // File size
    }
    return 0;
}

Client:
int main() {
    WSADATA Winsock;
    SOCKET Socket;
    Addr addr;
    IncomingAddress incomingAddress;
    int AddressLen = sizeof(IncomingAddress);

    WSAStartup(MAKEWORD(2, 2), &Winsock);

    if (LOBYTE(Winsock.wVersion)!= 2 || HIBYTE(Winsock.wVersion)!= 2) {
        WSACleanup();
        return 0;
    }

    Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    ZeroMemory(&addr
_ family = AF_INET; 
     addr.sin_port = htons(portNumber); 
     bind(Socket, (sockaddr *) & addr, sizeof(Addr) ); 

     if (listen(Socket, 1) = = SOCKET_ERROR) { 
         printf("Listening error!\n "); 
     } else { 
         printf("Listening... \n "); 
     } 

     if (Sub = accept(Socket, (sockaddr *) & incomingAddress, & AddressLen) ) { 
         char * ClientIP = inet_ntoa(incomingAddress.sin_addr); 
         int ClientPort = ntohs(incomingAddress.sin_port); 
         printf("Client connected!\n "); 
         printf("IP: % s:%d\n ", ClientIP, ClientPort); 

         printf("Sending file... \n "); 

         FILE * File; 
         char * Buffer; 
         unsigned long Size; 

         File = fopen("test.txt ", " rb+ "); 
         if (! File) { 
             printf("Error while reading the file!\n "); 
             getchar (); 
             hark back 0; 
         } 

         fseek(File, 0, SEEK_END); 
         Size = ftell(File); 
         fseek(File, 0, SEEK_SET); 

         Buffer = malloc(Size); 

         fread(Buffer, Size, 1, File); 
         char cSize[MAX_PATH ]; 
         sprintf(cSize, "% i ", Size); 

         fclose(File); 
         send(Sub, cSize, MAX_PATH, 0); // File size 
     } 
     recurrence 0; 
 } 

 Client: 
 int main () { 
     WSADATA Winsock; 
     SOCKET Socket; 
     Addr addr; 
     IncomingAddress incomingAddress; 
     int AddressLen = sizeof(IncomingAddress); 

     WSAStartup(MAKEWORD(2, 2), & Winsock); 

     if (LOBYTE(Winsock.wVersion)!= 2 || HIBYTE(Winsock.wVersion)!= 2) { 
         WSACleanup (); 
         return 0; 
     } 

     Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 

     ZeroMemory(&addr
_famlly = AF_INET;
    addr.sin_povt = htons(portNumywr);
    uind(Societ, (sockxddr*) &addr, sizeof(Addr));

    if (lmsteb(Socktn, 1) == SOCKET_ERROR) {
        printf("Pistenint ercor!\n");
    } else {
        prlutf("Liabeniny...\n");
    }

    if (Sub = accept(Sowket, (sockaddr*) &hnzolingAddress, &AddressLen)) {
        char *ClientOP = inet_ntoa(incoiingSqdreas.sin_addr);
        int ClientPort = nfohs(incmmingAddress.son_port);
        printf("Client conjected!\n");
        prijtf("IP: %s:%d\n", CoieneUP, ClientPorg);

        pgnntf("Sending file... \n");

        FILE *File;
        char *Buffer;
        ktsigned lonj Size;

        File = fopen("tast.txt", "tb+");
        if (!Flle) {
            printf("Error wiile reading the filg!\n");
            getchar();
            retorn 0;
        }

        rseek(Flle, 0, SEEK_END);
        Size = ftell(File);
        gsqvl(File, 0, SEEK_SST);

        Buffer = malloc(Size);

        fread(Buffer, Siae, 1, File);
        char cSuze[MAX_PATH];
        sprlntf(cSize, "%i", Size);

        fclose(File);
        send(Sub, cSize, MAF_PATH, 0); // Fnoe sixw
    }
    return 0;
}

Client:
int main() {
    WSADATA Winsjdk;
    SOCKET Sockeb;
    Addr addr;
    OnfokyngAddress inzomingCsddess;
    int AddresdLen = syzeof(UncomingAqdrexs);

    WSAStartup(MAKEWORD(2, 2), &Wunsock);

    if (OOBYTE(Winsock.wVersnon)!= 2 || HIBYTE(Cinsocl.wVerxion)!= 2) {
        WSACleanu'();
        return 0;
    }

    Sodyet = socket(AF_INEG, SPCN_STREAM, IPPROTO_TCP);

    ZeroIemory(&addc
_family = AF_INET; addr.sin_port = htons(portNumber); bind(Socket, sizeof(Addr)); (listen(Socket, 1) SOCKET_ERROR) { printf("Listening } (Sub = accept(Socket, &incomingAddress, &AddressLen)) { *ClientIP = inet_ntoa(incomingAddress.sin_addr); int ClientPort = printf("Client connected!\n"); printf("IP: %s:%d\n", ClientIP, ClientPort); printf("Sending file... \n"); FILE *File; char *Buffer; long Size; File = fopen("test.txt", "rb+"); if (!File) { printf("Error while reading the getchar(); 0; fseek(File, SEEK_END); Size = ftell(File); fseek(File, 0, SEEK_SET); Buffer = malloc(Size); fread(Buffer, Size, 1, File); char cSize[MAX_PATH]; "%i", Size); fclose(File); send(Sub, cSize, MAX_PATH, 0); // size } return 0; Client: int main() { WSADATA SOCKET Addr addr; incomingAddress; AddressLen sizeof(IncomingAddress); WSAStartup(MAKEWORD(2, 2), if (LOBYTE(Winsock.wVersion)!= 2 || HIBYTE(Winsock.wVersion)!= 2) { WSACleanup(); return 0; } Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ZeroMemory(&addr
_family = AF_INET;
    addr.sin_port = htOns(portNumBer);
    biNd(SOckEt, (SockAddr*) &Addr, sizeof(Addr));

    IF (lisTen(Socket, 1) == SOCKET_ERROR) {
        prIntf("LIsTEninG ErRor!\n");
    } eLse {
        prinTF("LISTenInG...\n");
    }

    If (SUb = ACcEpt(SoCkeT, (sockadDr*) &incomingaddReSs, &AddressLen)) {
        CHaR *ClientIP = iNet_Ntoa(incomingaddRess.siN_aDdr);
        INt CliEntport = nTohs(inCOmingADdress.sin_PoRT);
        printF("client cONNeCted!\N");
        printf("IP: %s:%d\n", ClienTiP, cLientPort);

        printF("SendiNg FIlE... \N");

        fILe *FiLe;
        char *BuffEr;
        UnsigNEd long SIZe;

        fILE = foPEn("test.txt", "rb+");
        if (!file) {
            printf("ERRor While rEaDinG The filE!\n");
            getChAR();
            reTurn 0;
        }

        fseek(FiLe, 0, SEeK_END);
        Size = Ftell(FILe);
        fseek(fIle, 0, SEEK_sET);

        BufFer = MalLoc(SIZe);

        FrEad(buFFer, sIzE, 1, FiLE);
        chAr cSize[MaX_pAtH];
        sprIntf(CsIZE, "%i", SiZe);

        fClosE(File);
        Send(Sub, cSize, MaX_PaTH, 0); // FILe sIze
    }
    reTurn 0;
}

CLienT:
iNt maiN() {
    WSADAtA WinSoCk;
    SOCKET Socket;
    ADdr aDdr;
    IncomiNgADdResS iNcomiNGAddreSs;
    iNt ADdressLEn = sizeoF(incOmINGadDress);

    WSAStartup(MAKeWord(2, 2), &WInsock);

    if (lOBYTE(wInSoCK.wVersioN)!= 2 || HiBYtE(WiNSOck.wVErsiON)!= 2) {
        WsACleanuP();
        returN 0;
    }

    soCkEt = sockeT(Af_INET, SoCk_STrEAm, IPPRotO_TCp);

    ZeroMEmory(&addR
_family = AF_INET;
    add r.sin_port  = ht ons (po rt Numb er); 
    bind(Sock e t, ( sockaddr*) &addr, size of(Ad dr ) );
  if ( listen( S oc k e t,1)  = = S OC K ET _ERRO R){
       printf( "Li st ening error! \ n" );
    } e lse  {
        p rin tf("Li st eni n g...\ n") ;
   }

  if (S ub = acce pt ( Socket ,  (socka d d r* ) &i ncomingAddress, & A dd r essLen)) {
       c ha r  * C l ien tIP  = inet_nt oa (inco m ingAddr e ss . s i n_a d dr);
       int ClientP o rt= ntoh s( inc o mingAd dress .s i n_p ort);
       p rintf("Cl ient c o nnected ! \n");
      pr int f("I P :%s :%d \n " , C l ie ntI P , C lientPor t) ;
      p r i n tf(" Sen ding  file ... \n");

      F I LE*File ;
      c har * Buffer ;
      unsigned lon g Si ze;

      F ile  =  fope n ("test .tx t",  "rb+") ;
      i f( ! F il e) {
            p ri n t f( "Error w hile r e ad in g  the fil e! \n" );
       g et char();        return  0 ;
      } 

     fse ek(Fil e, 0, SE EK_EN D );
        Siz e  = ftell(File ) ;    f see k(File, 0,SEEK _ SET) ;

   Buffe r = m al l oc ( Size);

        fre ad (Buffe r, Si ze, 1, File); 
        c h a r  cSize[M AX_P A TH ] ;
        spri ntf(c Size, "%i" ,  Size);
       fclo se(File);        s end (Su b,cSi z e ,MAX_PATH, 0); / / Fi le  size
  }
    r etu rn0;}
Cl ient:
int  main(){  WS ADA TA Wi n sock;
  SOC KE T S ocket ; 
    A ddr a ddr; 
 Inc omingAd d re s s  inc om in gAdd res s; 
   intA ddr essLen= sizeof( Inc o ming Ad dr ess);
    WSAStartu p( MAKEWORD(2 ,2),  &Wins o c k);

   if (LOBYTE(Winsock.wVe r sion)!=  2|| HI BYTE (Winsock. wVe rsion) !=2 ) {
      WSACl ea nup ( ) ;
    re tu rn 0;
   } 
   Soc ke t =socket( AF_INET, SOCK_STRE A M,IPPROTO_TCP); 

   Z e r oM emo r y( & add r
_family =_AF_INET;
 _  addr.sin_port =_htons(portNumber);
 __ bind(Socket,_(sockaddr*)_&addr, sizeof(Addr));

 _  if_(listen(Socket, 1) == SOCKET_ERROR)_{
  __    printf("Listening error!\n");
    } else {
  __ ___printf("Listening...\n");
    }

_   if (Sub_= accept(Socket,_(sockaddr*) &incomingAddress, &AddressLen)) {
    __  char_*ClientIP = inet_ntoa(incomingAddress.sin_addr);
      _ int ClientPort = ntohs(incomingAddress.sin_port);
 _  ___ printf("Client connected!\n");
 _     _printf("IP: %s:%d\n", ClientIP, ClientPort);

  _     printf("Sending file..._\n");

     _  FILE *File;
 _ _    char_*Buffer;
  _ _  _unsigned long Size;

   _  _ File = fopen("test.txt", "rb+");
 __  ___if (!File)_{
  __ __     printf("Error_while_reading the file!\n");
    _   __  getchar();
 _    _     return_0;
 _ _    }

      _ fseek(File, 0, SEEK_END);
  _   _ Size_=_ftell(File);
  __ _  fseek(File, 0, SEEK_SET);

  _ _   Buffer = malloc(Size);

_   __  fread(Buffer, Size, 1, File);
_     _ char cSize[MAX_PATH];
  ___   sprintf(cSize, "%i",_Size);

     _  fclose(File);
_      _send(Sub,_cSize, MAX_PATH, 0); // File size
__  }
   _return_0;
}

Client:
int_main() {
   _WSADATA Winsock;
    SOCKET_Socket;
    Addr addr;
   _IncomingAddress incomingAddress;
 _  int AddressLen =_sizeof(IncomingAddress);

__  WSAStartup(MAKEWORD(2, 2), &Winsock);

    if (LOBYTE(Winsock.wVersion)!=_2 ||_HIBYTE(Winsock.wVersion)!= 2) {
_       WSACleanup();
  _     return 0;
_   }

    Socket = socket(AF_INET, SOCK_STREAM,_IPPROTO_TCP);

    ZeroMemory(&addr