EmbLogic's Blog

Code that uses AF_INET address family to implement chatting between client and server through loopback address.

RCS file: server.c,v
Working file: server.c
head: 1.15
branch:
locks: strict
root: 1.15
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Code to demonstrate how a server accepts connections from a client on the same computer that is not networked.
This code uses AF_INET address family to implement a chatting between client and server through loopback address.
—————————-
revision 1.15    locked by: root;
date: 2014/02/05 23:03:13;  author: root;  state: Exp;  lines: +2 -2
Compilation error fixed.
Issue:Wrongly spelled function.
—————————-
revision 1.14
date: 2014/02/05 22:59:13;  author: root;  state: Exp;  lines: +1 -0
Header file:<pthread.h> is included to support pthread related function calls.
Checking……
—————————-
revision 1.13
date: 2014/02/05 22:58:09;  author: root;  state: Exp;  lines: +10 -0
Outside main(),the functionality of the reader thread is implemented.
Checking……
—————————-
revision 1.12
date: 2014/02/05 22:55:49;  author: root;  state: Exp;  lines: +9 -0
The functionality of the writer thread is implemented.
Now doing the same for reader thread……….
—————————-
revision 1.11
date: 2014/02/05 22:51:23;  author: root;  state: Exp;  lines: +2 -1
The prototypes of the two functions are declared that will be executed by the created threads.
Defining their body………….
—————————-
revision 1.10
date: 2014/02/05 22:48:42;  author: root;  state: Exp;  lines: +10 -1
Two threads are created using pthread_create() system call.The client_sockfd is passed as an argument.
—————————-
revision 1.9
date: 2014/02/05 22:03:58;  author: root;  state: Exp;  lines: +1 -1
Declaration error fixed.
Issue:Client_sockfd variable that will store the client socket descriptor is not declared.
Bugs fixed.
—————————-
revision 1.8
date: 2014/02/05 22:02:43;  author: root;  state: Exp;  lines: +1 -1
A logical error fixed.
Issue:Too many arguments are passed inside the bind() system call.
—————————-
revision 1.7
date: 2014/02/05 22:01:27;  author: root;  state: Exp;  lines: +3 -0
Header files:types.h , in.h and socket.h are included to support socket related functions.
—————————-
revision 1.6
date: 2014/02/05 21:58:47;  author: root;  state: Exp;  lines: +8 -2
accept() system call is used to accept the connection request from the client.
On error an error will get displayed on the screen.On success a client socket descriptor gets returned.
Checking ……
—————————-
revision 1.5
date: 2014/02/05 21:54:51;  author: root;  state: Exp;  lines: +7 -1
A socket queue is created for the incoming connection requests from the clients.
On error:a message will get displayed on the screen.
—————————-
revision 1.4
date: 2014/02/05 21:52:57;  author: root;  state: Exp;  lines: +1 -0
Header file:<stdlib.h> is included to support exit() function.
—————————-
revision 1.3
date: 2014/02/05 21:50:19;  author: root;  state: Exp;  lines: +11 -1
bind() system call is used to bind a name to socket.
If error occurs then an error message will get displayed.
—————————-
revision 1.2
date: 2014/02/05 21:41:39;  author: root;  state: Exp;  lines: +3 -1
A structure variable of type sockaddr_in is declared.
Previously,socket() system call is used that will return the socket descriptor.
Now making the bind call……
—————————-
revision 1.1
date: 2014/02/05 21:39:43;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: client.c,v
Working file: client.c
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
Code for the client program that requests a server for the connection.
—————————-
revision 1.7    locked by: root;
date: 2014/02/05 23:07:24;  author: root;  state: Exp;  lines: +3 -3
Several logical bugs fixed.
Issue:Wrongly placed variables.
—————————-
revision 1.6
date: 2014/02/05 23:00:22;  author: root;  state: Exp;  lines: +1 -0
Header file:<pthread.h> is included to support thread related functions.
—————————-
revision 1.5
date: 2014/02/05 22:53:05;  author: root;  state: Exp;  lines: +2 -2
The prototypes of the functions are changed.
—————————-
revision 1.4
date: 2014/02/05 22:42:00;  author: root;  state: Exp;  lines: +18 -0
The function that will be executed by the reader and writer threads are defined.
Checking the functionality……..
—————————-
revision 1.3
date: 2014/02/05 22:34:58;  author: root;  state: Exp;  lines: +5 -2
Prototypes of the two functions that will be used by the reader and writer threads are declared.
—————————-
revision 1.2
date: 2014/02/05 22:31:05;  author: root;  state: Exp;  lines: +9 -1
Two threads:namely reader and writer threads are declared of pthread_t.
pthread_create() is used to create the thread.
Using pthread_join to make the main thread to wait for the two child threads.
—————————-
revision 1.1
date: 2014/02/05 22:25:41;  author: root;  state: Exp;
Initial revision
=============================================================================

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>