hi,
i am doing a project in c(linux).the topic is authenticating and authorizing the client before accessing the file from the server.i already wrote the code for creating a client and server with allowing access to 10 client.for authentication if u cant give some tips or code please do reply.

Sure. Stop hijacking old threads. Read the Forum Rule. Check out the Sticky Posts before posting again.

  1. Post moved to new thread
  2. i already wrote the code for creating a client and server with allowing access to 10 client.

    So why don't yo post your code and ask questions in regards of your code?

  3. for authentication if u cant give some tips or code please do reply.

    Why you begging for tips and code when you just said you have code? Either way forum rule clearly state We only give homework help to those who show effort

  4. Make your arrangement in regards of our rules or ...

hi, i actually wanted a c code for sjf but im not able to get an idea for the starting time can any one help me out in this.........
please mail the idea to <EMAIL SNIPPED>
thank u......

Edited 6 Years Ago by peter_budo: Keep It On The Site - Do not post asking for an answer to be sent to you via email or PM.

Comments
If you posted that, after reading the previous reply, you're too dumb to be worth the effort

hi, i actually wanted a c code for sjf but im not able to get an idea for the starting time can any one help me out in this.........
please mail the idea to <EMAIL SNIPPED>
thank u......

Read my above reply and consider your options. Laziness is not welcome here.

1.i already wrote the code for creating a client and server with allowing access to set of client.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<unistd.h>
#include<signal.h>
        

 
   // SERVER SOCKET THREAD CREATION
   void *server_thread(void *arg)
   {
      int sock,len,ret,addrlen,rc;
      int opt=1 , bufsize = 11;
      char *IP = "127.0.0.1";
      char *buf = malloc(bufsize);          //Memory allocation for the Buffer
      struct sockaddr_in client , server;


      // SETTING THE SOCKET PARAMETERS
      server.sin_family = AF_INET;
      server.sin_addr.s_addr = inet_addr( IP );
      server.sin_port = htons(8000);
 
           
    

     // CREATING THE SOCKET AT THE SERVER END
     sock = socket(AF_INET , SOCK_STREAM ,0);
     if(sock == -1)
     {
          printf("ERROR in socket creation");
     }

    
    // BINDING THE SOCKET
    bind(sock , (struct sockaddr *) &server ,sizeof(server) );

    // LISTEN FOR TO CLIENT CONNECTION REQUEST
    listen(sock ,3);

    addrlen = sizeof(struct sockaddr_in);

   // ACCEPT THE CONNECTION FROM CLIENT
   ret = accept(sock , (struct sockaddr *)&client , &addrlen);

   // RECEIVE THE DATA FROM CLIENT
   while(1)
   {
    rc = recv(ret , buf , bufsize , 0);
       if(rc > 0)
       { 
         printf("\n\n\n  Received Data From Client = %s \n\n\n\n", buf);
         sleep(1);
       }
       else
       {
         printf(" Some ERROR occured in socket connection \n");
       }
   }
}

   
  // Main() OF SERVER
  int main()
  {
    
    pthread_t thid;
    pthread_create(&thid ,NULL ,server_thread ,NULL);

    
  
    while(1) 
   {   }
 
    return 0;
  }

2.so now there is an error in main function.
3.can u please help me out to solve it.
4.the above mentioned was the server side.
5.the client side programming is written below.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<unistd.h>
#include<sys/poll.h>
#include<signal.h>

//Local Machine IP
char *IP = "127.0.0.1";
 

   // CLIENT SOCKET THREAD
    void *client_thread(void *arg)
   {
      int sock;
      int opt=1 , ret;
      char buf[] = "HELLO WORLD";
      struct sockaddr_in client , server;

      // SETTING THE SOCKET PARAMETERS
      client.sin_family = AF_INET;
      client.sin_addr.s_addr = inet_addr( IP );   
      client.sin_port = htons(7000);
     
      server.sin_family = AF_INET;
      server.sin_addr.s_addr = inet_addr( IP );
      server.sin_port = htons(8000);
 
       
     // CREATING THE SOCKET AT THE CLIENT END
     sock = socket(AF_INET , SOCK_STREAM ,0);
     if(sock == -1)
     {
          printf("ERROR in socket creation");
     }

    // SETTING THE SOCKET OPTIONS
    // setsockopt(sock , SOL_SOCKET
 
    // BINDING THE SOCKET
    bind(sock , (struct sockaddr *) &client ,sizeof(client) );

    // CONNECTING TO SERVER 
    connect(sock , (struct sockaddr *) &server ,sizeof(server) );

    //SENDING DATA TO SERVER
    while(1)
    { 
      send(sock ,buf ,strlen(buf) , 0);
    }
  }


  // Main() OF CLIENT
  int main()
  {
    
    pthread_t thid;
    pthread_create(&thid ,NULL ,client_thread ,NULL);

    while(1)
    {   }
 
    return 0;
  }

6.so can u help me to run this programm with 10 clients.and that pthread problem in main function.

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This article has been dead for over six months. Start a new discussion instead.