client.c File Reference

This program acts like client which first connects to the server by the information provided by the user like Server IP address, Port Number, Nick Name, then the client can sent messages and recieve messages from all other clients. More...

#include "client.h"

Go to the source code of this file.

Functions

void end_program (GtkWidget *widget1, gpointer data)
 This function calls when we close the window.
void onExit (GtkWidget *window, gpointer data)
 This function calls when we close the window.
void add_widget_with_label (GtkContainer *box, gchar *caption, GtkWidget *widget)
 This function adds the widget to the Box with corresponding label passed.
void close_properly ()
 This function is called when we press Ctrl+C key or on any error condition.
void msg_func (GtkWidget *widget1, gpointer data)
 This function is called when we enter some message in the GTK entry.
void connect_server (GtkWidget *widget1, gpointer data)
 This function is called when "connect" button is pressed.It connects to the server with the information provided by the user(like server IP, client Nick, Port).
void * start_client (void *arg)
 This function starts the client side of Messenger after succesfully connecting to the server.
int main (int argc, char *argv[])
 This is where program execution starts.


Detailed Description

This program acts like client which first connects to the server by the information provided by the user like Server IP address, Port Number, Nick Name, then the client can sent messages and recieve messages from all other clients.

The client can also see the list of all other connected clients..

Author:
Ratna Kumar K.V.R

Definition in file client.c.


Function Documentation

void add_widget_with_label ( GtkContainer *  box,
gchar *  caption,
GtkWidget *  widget 
)

This function adds the widget to the Box with corresponding label passed.

Parameters:
box Box into which widget has to be packed
caption label to be given.
widget widget to be packed.

Definition at line 37 of file client.c.

Referenced by main().

void close_properly (  ) 

This function is called when we press Ctrl+C key or on any error condition.

It does proper closing of file descriptors.

Definition at line 50 of file client.c.

References socket_file_descriptor.

Referenced by msg_func(), and start_client().

void connect_server ( GtkWidget *  widget1,
gpointer  data 
)

This function is called when "connect" button is pressed.It connects to the server with the information provided by the user(like server IP, client Nick, Port).

If the connection is successful it displays the chat Room, else it displays appriopriate dialog message.

Parameters:
widget1 "connect" button
data pointer

Definition at line 82 of file client.c.

References BUFFER, entry_ipaddress, entry_nick, entry_port, client_data::fd, client_data::ip, ip, list_store, client_data::nick, nick, socket_file_descriptor, and t_iter.

Referenced by main().

void end_program ( GtkWidget *  widget1,
gpointer  data 
)

This function calls when we close the window.

. which quits the window and exits the program. It shutdowns the socket and closes all the widgets.

Parameters:
widget1 Widget to be closed
data pointer

Definition at line 16 of file client.c.

References socket_file_descriptor.

Referenced by main().

int main ( int  argc,
char *  argv[] 
)

This is where program execution starts.

All arguments are passed to gtk for processing, which removes any arguments relevant to it. All other arguments are ignored. This function first gets a window for user to enter Server IP Address, port and Nick of client. If it can connect succesfully then it displays the chat room, else it displays the dialog box with approriate message.

Parameters:
argc Number of arguments passed.
argv NULL terminated array of command line arguments.
Returns:
EXIT_SUCCESS on success, EXIT_FAILURE on failure

Definition at line 255 of file client.c.

References add_widget_with_label(), buffer, connect_server(), end_program(), entry, entry_ipaddress, entry_nick, entry_port, iter, list_store, msg_func(), onExit(), and start_client().

void msg_func ( GtkWidget *  widget1,
gpointer  data 
)

This function is called when we enter some message in the GTK entry.

It sends the message to the server.It prints appropriate error message and closes all connections if sending fails..

Parameters:
widget1 GTK entry
data pointer

Definition at line 62 of file client.c.

References close_properly(), entry, msg, and socket_file_descriptor.

Referenced by main().

void onExit ( GtkWidget *  window,
gpointer  data 
)

This function calls when we close the window.

. which quits the window and exits the program. so it shutdowns and closes all the connections.

Parameters:
window Widget to be closed
data pointer

Definition at line 27 of file client.c.

Referenced by main().

void* start_client ( void *  arg  ) 

This function starts the client side of Messenger after succesfully connecting to the server.

It can send messages to and recieve messages from all other connected clients and can also see the list of connected clients

Parameters:
arg paramters

Definition at line 167 of file client.c.

References buffer, BUFFER, close_properly(), transmit_unit::ip, ip, iter, list_store, transmit_unit::msg, transmit_unit::nick, socket_file_descriptor, t_iter, and transmit_unit::time.

Referenced by main().


Generated on Wed Apr 7 17:03:11 2010 for LAN-Messenger(Client) by  doxygen 1.5.8