Program for gateway process that simulates datagram loss

This is a discussion on Program for gateway process that simulates datagram loss within the Networking/Device Communication forums, part of the General Programming Boards category; Hey guys, Need your help with some code here: Trying to create a gateway process that simulates datagram loss. It's ...

  1. #1
    Gal
    Gal is offline
    Registered User
    Join Date
    Dec 2009
    Posts
    1

    Program for gateway process that simulates datagram loss

    Hey guys,

    Need your help with some code here:

    Trying to create a gateway process that simulates datagram loss.
    It's build from 3 C programs thats run on Linux.

    The first link - is the code of Sink.c: - the code is fine i think - but not sure.
    pastebin - collaborative debugging tool

    Second link is the one that i have problem with - gateway.c:
    pastebin - collaborative debugging tool
    */my error appears after i running the source.c program - error : segmentation fault ! /*

    The 3rd link - is the code of Sink.c:
    pastebin - collaborative debugging tool

    I need to run them all and source.c need to go through the gateway and to the sink.c.

    Please help . . .

  2. #2
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    um you have Sink.c listed twice and source.c listed not at all...was this a typo? And what is pastebin - collaborative debugging tool? Finally I would suggest running gateway.c under GDB and when the segfault hits, do a "where" to show the exact line and cause of the segfault. If this does not clear things up Gal I would request that you supply a little more information about the *intent* of the three programs, how they are supposed to interact, etc...


    Peace bro...

    Jeff
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #3
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Oh and while others may not have a problem with this, posting code with line numbers (IOW not ready to compile) slows the help process....

    BTW what is this?
    Code:
    */running to the localhost/*
     
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <inttypes.h>
    #include <netdb.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <strings.h>
    #include <unistd.h>
     
    int main(int argc, char *argv[])
    {
      int socket_fd;
      struct sockaddr_in  dest;
      struct hostent *hostptr;
      struct { char head; u_long body; char tail; } msgbuf;
     
      socket_fd = socket (AF_INET, SOCK_DGRAM, 0);
     <snip>
       unsigned sleep(unsigned seconds); <<== looks like you are declaring a function, not calling one...???
    }
     
      return 0;
    }
    Also your comment tags are backwards at the top of the file negating the first 20 or so lines of the code....

    J.
    Last edited by jeffcobb; 12-20-2009 at 12:23 PM. Reason: Added question...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Looking at the source for sink.c....

    Is it your intent to send the process ID of the sink program over and over to argv[1]? I only ask b/c that seems to be at odds with what your original question claimed (sending source.c to another socket).....I guess I am confused...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  2. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  3. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21