Results 1 to 6 of 6

Thread: Client and Server Programming In C

  1. #1
    Join Date
    Jan 2009
    Posts
    66

    Client and Server Programming In C

    Hello, I am a student of BSC.I.T. and while learning the C language I want to know the Client and Server Programming in C language. But, as it is not in our syllabus I am not able to get it. So, if anyone is having details about it, then please provide me that. If you are having some or the other code then that will help me more. So, please reply me with some useful details about the Client and Server Programming In C. Is there any book available on this?

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Client and Server Programming In C

    Client and server programming mostly done for the File transfer through Socket. For that you can make use of C. The user selected the file server that the client can download, the server accepts the connection, sends data and closes the connection. The client connects via the server's IP address [name resolution domain has come], download the file and closes the connection.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Client and Server Programming In C

    Client and Server Programming In C is based on the Network programming which is based on sockets. The sockets are a standard mode of communication on the network, developed at Berkeley, which allow an application to interact with a protocol. It can be done on the same machine or on a remote machine via a network.
    There are two modes of communications for LGA:
    • the connected mode, which uses TCP
    • disconnected mode, based on UDP

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Client and Server Programming In C

    I am not having more knowledge about the C language. But, I have one program on this which can help you a lot for getting information about it.
    Client side program:
    Code:
    #ifdef code
    #include <config.h>
    #endif
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <unistd.h>
    int main(int argument, char *args[])
    {
       printf("Client Side programming");
       int sock;
       int size;
       struct Address address;
       int answer;
       char ch = 'A';
       sock = socket(AF_INET, SOCK_STREAM, 0);
       address.sin_family = AF_INET;
       address.sin_addr.s_addr = inet_addr("127.0.0.1");
       address.sin_port = htons(7734);
       size = sizeof(address);
       answer = connect(sock, (struct sockaddr *)&address, size);
       if(answer == 1)
       {
          perror("Error has occurred");
          exit(0);
       }
       write(sock, &ch, 1);
       read(sock, &ch, 1);
       printf("Char from server = %c\n", ch);
       close(sock);
       exit(0);
    }
    Server Side Program:
    Code:
    #ifdef code
    #include <config.h>
    #endif
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <unistd.h>
    int main(int argument, char *args[])
    {
       int server, client;
       int server_size, client_size;
       struct socaddress server_address;
       struct socaddress client_address;
       server = socket(AF_INET, SOCK_STREAM, 0);
       server_address.sin_family = AF_INET;
       server_address.sin_addr.s_addr = htons(INADDR_ANY);
       server_size = sizeof(server_address);
       bind(server, (struct sockaddr *) &server_address, server_size);
       listen(server, 5);
       while(1)
       {
          char ch;
          printf("server waiting\n");
          client_size = sizeof(client_address);
          client = accept(server, (struct sockaddr *) &client_address, &client_size);
          read(client, &ch, 1);
          ch++;
          write(client, &ch, 1);
          close(client);
       }
       return 0;
    }

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Client and Server Programming In C

    With sockets C you will be able to exchange blocks of data (or messages) between clients and servers. It will take "over" define and code a protocol that allows entities to act on the content of these messages. RMI stands for "Remote Method Invocation". Briefly, this is already a protocol and it allows you to operate the methods of a remote object. This is not quite the same level of abstraction. After all depends on what you want to do and what will enable you to achieve more easily.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Client and Server Programming In C

    You can refer one of the following book for getting more knowledge:
    • Object-Orientated Programming with ANSI-C
    • C - Committee Draft of ISO9899:TC2
    • C - The ISO Standard - Rationale
    • C - Elements of Style
    • Numerical Recipes in C - The Art of Scientific Computing
    • The C Book
    • Writing Bug Free C Code

Similar Threads

  1. Give some of the programming Language combinations for web server?
    By Mystic01 in forum Software Development
    Replies: 4
    Last Post: 06-06-2011, 08:33 AM
  2. Replies: 7
    Last Post: 16-02-2011, 08:14 PM
  3. PHP server side programming
    By MAHESA in forum Software Development
    Replies: 5
    Last Post: 04-11-2009, 11:29 PM
  4. Problem in MMORPG Client/Server Network Programming
    By Jagdish Gada in forum Software Development
    Replies: 3
    Last Post: 24-02-2009, 01:49 PM
  5. Replies: 3
    Last Post: 13-12-2008, 01:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,312,937.26428 seconds with 16 queries