Translate

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, 28 July 2019

Solved- webmin has a libnet-ssleay-perl problem

Initially I was confused, I tried so many ways but I still get error.

1- sudo apt-get update
and I get-
Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu bionic-proposed InRelease
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Fetched 19.3 kB in 3min 42s (87 B/s)
Reading package lists... Done
2- sudo apt-get upgrade
and I get This Error-
update-initramfs: Generating /boot/initrd.img-4.18.0-25-generic
I: The initramfs will attempt to resume from /dev/sda2
I: (UUID=7617de5b-de18-429b-839e-adb13a5646cd)
I: Set the RESUME variable to override this.
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
this will download the package.
 sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl
but still I was getting Error anfter that I tried 
sudo apt-get install apt-show-versions

Then I get below error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-show-versions
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 28.6 kB/312 kB of archives.
After this operation, 93.2 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 apt-show-versions all 0.22.7ubuntu1 [28.6 kB]
Fetched 28.6 kB in 0s (62.8 kB/s)            
Selecting previously unselected package apt-show-versions.
(Reading database ... 161378 files and directories currently installed.)
Preparing to unpack .../apt-show-versions_0.22.7ubuntu1_all.deb ...
Unpacking apt-show-versions (0.22.7ubuntu1) ...
Setting up apt-show-versions (0.22.7ubuntu1) ...
** initializing cache. This may take a while **
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get -f install

After this try I get again below Error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/284 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get autoremove libnet-ssleay-perl
This will remove 
libnet-ssleay-perl but still I get below error-

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libapt-pkg-perl is already the newest version (0.1.33build1).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/284 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get install --reinstall libnet-ssleay-perl 

And this solved my problem. after this I
sudo apt-get update
and 
sudo apt-get upgrade

and I found problem has been solved

sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04
  linux-image-generic-hwe-18.04
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

Thursday, 1 November 2018

Simple Data Structure Implementation


Data Structure Basic Concept and Program using C language

Include the header file 
#include <stdio.h>
#include <stdlib.h>

Define the Node Strucure
struct Node{
 int data;
 struct Node* next;
};

Function to add data on begining
void addBegning(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = *head;
 *head = newNode;
}

Function to add data at last position
void addLast(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* last = *head;
 newNode->data = newData;
 newNode->next = NULL;
 if(*head == NULL){
  *head = newNode;
  return;
 }
 while(last->next != NULL){
  last = last->next;
 }
 last->next = newNode;
 return;
}

Inserting data after some node
void insertAfter(struct Node* head, int newData){ 
 if(head == NULL) return;
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = head->next;
 head->next = newNode;

}

Deleting a element from data structure
void deleteElement(struct Node** head, int element){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* temp = *head, *prev;
 if(temp != NULL && temp->data == element){
  *head = temp->next;
  free(temp);
  return;
 }
 while(temp != NULL && temp->data != element){
  prev = temp;
  temp = temp->next;
 }
 if(temp == NULL){ printf("Element does not exist in list"); return;}
 prev->next = temp->next;
 free(temp);
}

Reverse the Linked List
static void reverseList(struct Node** head){
 struct Node* current = *head;
 struct Node* next = NULL;
 struct Node* prev = NULL;
        while(current != NULL){
              next = current->next;
                current->next = prev;
                prev = current;
                current = next;
        }
 *head = prev;
}

Print the data
void printData(struct Node* node){
 while(node != NULL){
  printf("%d\t", node->data);
  node = node->next;
 }
 printf("\n");
}

Main 
int main(){
 struct Node* head = NULL;
 addBegning(&head, 2);
 addBegning(&head, 50);
 addBegning(&head, 9);
 addLast(&head, 10);
 addLast(&head, 25);
 insertAfter(head->next->next, 30); //head-1, head->next-2, head->next->next-3
 printf("Before Deletion\n");
 printData(head);
 deleteElement(&head, 30);
 printf("After Deletion element 30\n");
 printData(head);
 printf("After Reverse Linked list\n");
 reverseList(&head);
 printData(head);
 return 0;
}

One File Program 
#include <stdio.h>
#include <stdlib.h>

struct Node{
 int data;
 struct Node* next;
};

void addBegning(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = *head;
 *head = newNode;
}
void addLast(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* last = *head;
 newNode->data = newData;
 newNode->next = NULL;
 if(*head == NULL){
  *head = newNode;
  return;
 }
 while(last->next != NULL){
  last = last->next;
 }
 last->next = newNode;
 return;
}
void insertAfter(struct Node* head, int newData){ 
 if(head == NULL) return;
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = head->next;
 head->next = newNode;

}
void deleteElement(struct Node** head, int element){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* temp = *head, *prev;
 if(temp != NULL && temp->data == element){
  *head = temp->next;
  free(temp);
  return;
 }
 while(temp != NULL && temp->data != element){
  prev = temp;
  temp = temp->next;
 }
 if(temp == NULL){ printf("Element does not exist in list"); return;}
 prev->next = temp->next;
 free(temp);
}
static void reverseList(struct Node** head){
 struct Node* current = *head;
 struct Node* next = NULL;
 struct Node* prev = NULL;
        while(current != NULL){
              next = current->next;
                current->next = prev;
                prev = current;
                current = next;
        }
 *head = prev;
}
void printData(struct Node* node){
 while(node != NULL){
  printf("%d\t", node->data);
  node = node->next;
 }
 printf("\n");
}
int main(){
 struct Node* head = NULL;
 addBegning(&head, 2);
 addBegning(&head, 50);
 addBegning(&head, 9);
 addLast(&head, 10);
 addLast(&head, 25);
 insertAfter(head->next->next, 30); //head-1, head->next-2, head->next->next-3
 printf("Before Deletion\n");
 printData(head);
 deleteElement(&head, 30);
 printf("After Deletion element 30\n");
 printData(head);
 printf("After Reverse Linked list\n");
 reverseList(&head);
 printData(head);
 return 0;
}

Give Something to the world and it will never let you down.  
Onkar Dubey 




Service that allow to run a program on boot (Linux Platforn)



In this tutorial I will show you how you can run a program on boot (startup) using Linux platform this will work on all Linux distros
This service can run all type of executable file.
If you want to run you ".c" file, first compile it and put the compiled file name with the directory as written in Step-3 "ExecStart = "..........." and change the working directory directory in Step-3 WorkingDirectory= " ................" this directory is your executable file directory.

This is tested on Ubuntu 18.

Step 1- Go to system directory

$ cd /etc/systemd/system

Step 2- Open vi Edititor and write the service

$ vim myservice.service
Step 3- Paste the following code as instructed
--------------------------------------------------------------------------------------------------------------------------
[Unit]
# This is the name of service
Description=om service
[Service]
#User is as root, the program will run as root user
User=root
# The configuration file application.properties should be here:
#change this to your workspace
WorkingDirectory=/home/om/workplace
#path to executable. 
#put the executable file
ExecStart=/home/om/workplace/myprog
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
--------------------------------------------------------------------------------------------------------------------------

Step 4- Enable the service

$ sudo systemctl daemon-reload
$ sudo systemctl enable sample.service
$ sudo reboot
If You need any further query please send a message or comment.



Give Something to the world and it will never let you down.  
 
Onkar Dubey 
 




Friday, 16 February 2018

Textual description of firstImageUrl

How to check that How many IP Address connected to same Network



Hy Everyone Here I am providing a method to check IP Address connected on same Network I have verified it on linux (Ubuntu 16.04)
Just Provide your range that you are using after that click Enter
You will get all the IP Address connected to your Network

You can see this command on Picture as well as written the following. Please let me know if it did not work for you.


for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; 
    [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ;
 
 

Use nmap to check the route

check man nmap
 
 
Give Something to the world and it will never let you down.  
 
Onkar Dubey 
 
 
 
 
 

Monday, 29 January 2018

Textual description of firstImageUrl

Getting RMS Value from FFMPEG using C Language and setting up the Audio Level to use Train announcement System



Author Name : Onkar Dubey

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main()
{

    int  count = 0, flag = 1;
    FILE *pipein;
    pipein  = popen("ffmpeg -f alsa -i hw:0,0 -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level -f null - 2>&1", "r");

    char line[1024];
    char *s;
    double om_rms;

    while(1)
    {

        fscanf(pipein, "%[^\n]\n", line);

        s = strstr(line, "RMS_level");
        if (s)
        {
            s += 10;

            om_rms = atof(s);

            // Print the RMS value
            //fprintf(stderr, "  RMS_VALUE = %lf\n", om_rms);

                if(om_rms > -15.00000)
                {
                    count ++;
                    if((count == 10) && (flag == 1))
                        {
                        printf("Alert ON\n");
                        fprintf(stderr, "Train announcement is going on....Stop othe process\nRMS_VALUE = %lf dB\n\n", om_rms);
                        flag = 0;
                        }
                }
                else if (om_rms < -18.00000)
                {
                    count --;
                    if((count == -200) && (flag == 0))
                        {
                        printf("Alert OFF\n");
                        fprintf(stderr, "Train announcement have been stoped..... Start othe process\nRMS_VALUE = %lf dB\n\n", om_rms);
                        flag = 1;
                        }
                    else if (count < -200) count = -200;
                }
                else count = 0;
         }

}}




 To connect with socket

 server.c

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>


#include <stdio.h>
#include <string.h>
#include <stdlib.h>


void main(){

    char alert[10] = "Alert ON";
    char alert1[10] = "Alert OFF";
    int count = 0, flag = 1;
    FILE *pipein;
    pipein  = popen("ffmpeg -f alsa -i hw:0,0 -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level -f null - 2>&1", "r");

    char line[1024]; // longer than required - only stores one line of text at a time!
    char *s;
    double om_rms;

        int net_socket;
        net_socket=socket(AF_INET,SOCK_STREAM,0);

        struct sockaddr_in server_address;
        server_address.sin_family=AF_INET;
        server_address.sin_port=htons(2020);
        server_address.sin_addr.s_addr=INADDR_ANY;

        int k = bind(net_socket, (struct sockaddr *) &server_address, sizeof(server_address));
        if(k<0){
                printf("Error in socket binding");
        }
        listen(net_socket,6);

        int client_socket=accept(net_socket,NULL, NULL);





    while(1){
        // Read a line of text from the input pipe
        fscanf(pipein, "%[^\n]\n", line);

        // Find the substring "RMS_level" if it is present in this line
        s = strstr(line, "RMS_level");
        if (s){
            // Substring "RMS_level" was found, so jump to beginning of value
            s += 10;

            // Convert the value from a string (the rest of the line) to a double
            om_rms = atof(s);

            // Print the RMS value
            //fprintf(stderr, "  RMS_VALUE = %lf\n", om_rms);
            if(om_rms > -26.000000)
                {
                    count ++;
                    if((count == 10) && (flag == 1))
                        {
                        send(client_socket,alert,sizeof(alert),0);
                        printf("Alert ON\n");
                        fprintf(stderr, "User is Speaking, Stop othe process  RMS_VALUE = %lf\n\n", om_rms);
                        flag = 0;
                        }
                }
                else if (om_rms < -28.00000)
                {
                    count --;
                    if((count == -200) && (flag == 0))
                        {
                        int client_socket=accept(net_socket,NULL, NULL);
                        send(client_socket,alert1,sizeof(alert1),0);
                        printf("Alert OFF\n");
                        fprintf(stderr, "User is not speaking, Start othe process  RMS_VALUE = %lf\n\n", om_rms);
                        flag = 1;
                        }
                else if (count < -200) count = -200;
                }
                else count = 0;
         }
    }
}


Client.c


#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>


int main(){
        int network_socket;
    char recieve_msg[20];

        network_socket=socket(AF_INET,SOCK_STREAM,0);

        struct sockaddr_in server_address;
        server_address.sin_family=AF_INET;
        server_address.sin_port=htons(2020);
        server_address.sin_addr.s_addr=INADDR_ANY;

int connection_status = connect(network_socket, (struct sockaddr *) &server_address, sizeof(server_address));
        if(connection_status<0){
                printf("Error in connection\n");
        close(network_socket);
        }
    else {
    int ret = recv(network_socket,&recieve_msg,sizeof(recieve_msg),0);
while(1)
{
if(ret){
    printf("Recieved massage is:  %s\n: ",recieve_msg);
    }
}
close(network_socket);


return 0;
}
}

to execute the program run as
server side
$ gcc -o server server.c
$ ./server 2020
client side
$ gcc -o Client Client.c
$ ./Client 2020
     

I will make it more reliable to get that inbox me.
To know more detail inbox or comment on the comment box


                                      Give Something to the world and it will never let you down. 
                                                                                           Onkar Dubey 
 
 

Monday, 15 January 2018

Textual description of firstImageUrl

Proxychains


Proxychains

I am going to tell you how to use proxychains or proxy on Linux
First You need to check that you have proxychains.conf file or not

Open terminal Ctrl+Alt+t

Type 
sudo apt-get install proxychains
Enter Pass and Install the proxychais. If you have all ready then it's ok

Now Install tor by typing
sudo apt-get install tor

Now Open proxychains.conf File by using following command

sudo vi /etc/proxychains.conf

It will open like following figure







you are raedy to go
open terminal and type: $ service tor start
and the type proxychains firefox duckduckgo.com

                                      Give Something to the world and it will never let you down. 
                                                                                           Onkar Dubey 


Saturday, 9 December 2017

Port Programming

Port Programming 

Serial Port Opening and sending and accessing data using "AT" Commands

Instructions:

This code is verified in Linux Ubuntu 16.04.3 LTS

 First check the USB Port using following given command

echo Hello > /dev/pts/1
echo xyz > /dev/pts/2
echo ..... > /dev/pts/...
and so on...  put something on the position of ... when You get the response that means port can be use
exp:
echo Welcome > /dev/pts/6    hit enter
Welcome
if you get "Welcome" that means You can use that port.     
Change the path of the port in code and compile using
gcc -o serial_port serial_port.c
and run it using 
./serial_port

serial_port.c

#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <termios.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>

int main(){
    int fd;
    //char path[10];
    struct termios options;

    /* ################# Open the port #################*/

    printf("Enter com_port path\n sorry not now\n");
//    scanf("%c",&path);
    fd = open("/dev/pts/1", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
   {                                              /* Could not open the port */
     fprintf(stderr, "open_port: Unable to open /dev/pts/6 - %s\n",strerror(errno));
   }else{
printf("port opened\n");
    }

    fcntl(fd, F_SETFL, 0);

    /* ################ Get the current options ###############*/

    tcgetattr(fd, &options);

    /*############## set raw input, 1 second timeout */

    options.c_cflag     |= (CLOCAL | CREAD);
    options.c_lflag     &= ~(ICANON | ECHO | ECHOE | ISIG);
    options.c_oflag     &= ~OPOST;
    options.c_cc[VMIN]  = 0;
    options.c_cc[VTIME] = 10;

    /*################### set the options ##################*/

    tcsetattr(fd, TCSANOW, &options);

char buffer[400];  /* Input buffer */
      char *bufptr;      /* Current char in buffer */
      int  nbytes;       /* Number of bytes read */
      int  tries;        /* Number of tries so far */

      for (tries = 0; tries < 1; tries ++)
      {
       /* send an AT command*/
if (write(fd, "AT+CMGL=\"ALL\"\n", strlen("AT+CMGL=\"ALL\"\n")) < 3){
printf("command sent\n");
  continue;
if(write(fd, "AT+CMGL=\"ALL\"\r", strlen("AT+CMGL=\"ALL\"\r"))=="clc")
goto loop;

}



       /*################## Read characters into our string buffer ################*/

bufptr = buffer;

nbytes = read(fd, bufptr, buffer + sizeof(buffer) - bufptr - 1);
printf("%s\n",bufptr);

    char *p;

    p = strstr(buffer, "tin");
    printf("%s",p);

p = strstr(buffer, "server");
if(p == NULL) printf("not from server\n");
  *bufptr = '\0';
loop: close(fd);
 }

close(fd);
return 0;
}



                                      Give Something to the world and it will never let you down. 
                                                                                           Onkar Dubey 

Thursday, 16 November 2017

Textual description of firstImageUrl

UDP Implementation






       


Here's a simple UDP Server Client Implementation in C for Unix/Linux.
As UDP is a connection-less protocol, it is not reliable or we can say that we don't send acknowledgements for the packets sent.

Here is a concurrent UDP server which can accept packets from multiple clients simultaneously.
The port mentioned here can be changed to any value between 1024 and 65535 (since upto 1024 are known ports).
//UDPServer.c
/*
 *  gcc -o server UDPServer.c
 *  ./server
 */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define BUFLEN 512
#define PORT 9930
void err(char *str)
{
    perror(str);
    exit(1);
}
int main(void)
{

    
struct sockaddr_in my_addr, cli_addr;
    int sockfd, i;
    socklen_t slen=sizeof(cli_addr);
    char buf[BUFLEN];


/* ############### Socket Opening ############# */


    if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
      err("socket");
    else
      printf("Server : Socket() successful\n");
    bzero(&my_addr, sizeof(my_addr));
    my_addr.sin_family = AF_INET;
    my_addr.sin_port = htons(PORT);
    my_addr.sin_addr.s_addr = htonl(INADDR_ANY);


/* ############### Socket Binding ############## */    


    if (bind(sockfd, (struct sockaddr* ) &my_addr, sizeof(my_addr))==-1)
      err("binding Error");
    else
      printf("Server : bind() successful\n");


/* ################ Data Receiving ############### */


    while(1)
    {
        if (recvfrom(sockfd, buf, BUFLEN, 0, (struct sockaddr*)&cli_addr, &slen)==-1)
            err("recvfrom()");
        printf("Received packet from %s:%d\nData: %s\n\n",
               inet_ntoa(cli_addr.sin_addr), ntohs(cli_addr.sin_port), buf);
    }
    close(sockfd);
    return 0;
}

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//UDPClient.c
/*
 * gcc -o client UDPClient.c
 * ./client <server-ip>
 */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define BUFLEN 512
#define PORT 9930
void err(char *s)
{
    perror(s);
    exit(1);
}
int main(int argc, char** argv)
{
    struct sockaddr_in serv_addr;
    int sockfd, i, slen=sizeof(serv_addr);
    char buf[BUFLEN];
    if(argc != 2)
    {
      printf("Usage : %s <Server-IP>\n",argv[0]);
      exit(0);
    }



/* ############### Socket Opening ############# */


    if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
        err("socket");
    bzero(&serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(PORT);
    if (inet_aton(argv[1], &serv_addr.sin_addr)==0)
    {
        fprintf(stderr, "inet_aton() failed\n");
        exit(1);
    }



/* ############### Data Sending ############## */    

   
 while(1)
    {
        printf("\nEnter data to send(Type exit and press enter to exit) : ");
        scanf("%[^\n]",buf);
        getchar();
        if(strcmp(buf,"exit") == 0)
          exit(0);
        if (sendto(sockfd, buf, BUFLEN, 0, (struct sockaddr*)&serv_addr, slen)==-1)
            err("sendto()");
    }
    close(sockfd);
    return 0;
}