Connecting to a Server Program HELP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Connecting to a Server Program HELP

  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Connecting to a Server Program HELP

    I am currently attending a Networking Class at a Universtity. I have been given some homework and been told to do it. I need some help because i am very new to C coding. I have gone through and programed in C and know the basics. Unfortunately i have a teacher that is not a teacher but a programmer. he just goes through the class telling stories and such and expecting that we already know what he is telling us. We have tried to tell him we don't understand and nobody has finished the homework because they don't know how. I am wondering if there is anyone on here that could at least help me through with the homework (if not on here possibly through email ) and could work me through the homework problem. I really want to be able to UNDERSTAND it i don't want to just take the easy way out and have someone write the code for me.

    My teacher wrote super quickly one day the first part the homework and i will include it below because i cannot even get that to work. Im really stuck. if you would rather talk through email my email address is sedricbenson@hotmail.com. I would really appreciate any help you guys could give me on understanding programming a little better. What i mostly don't understand how to do is connect this to a server. ALSO I KNOW RIGHT NOW IT DOESN"T MAKE A DIFFERENCE NOW, BUT I AM ALSO PROGRAMMING WITH MACINTOSH X-CODE. IM NEW TO THIS TOO AND WOULD LIKE SOME HELP, although the code is the same for perl/c/c++ ect. I just know there might be a few different man calls etc.

    Heres the homework problem and here the program that gave us in class. Please let me know if u can help. Thank you so much:


    Homework #1:

    Write a program which does not use the client/server model. This program will read a line from the terminal, call a function to process the line, and then write the results back to the terminal. The input line should have the format of : OPERATOR:STRING where the operators indicated operations to be performed on the string. The operators are: r to reverse the order of the string, and c to reverse the case of the letters (change uppercase to lowercase and lowercase to uppercase). The function that processes the line will return a result in the same character array followed by a new line.


    NOW HERE IS THE CODE HE GAVE US IN CLASS:


    #!/usr/bin/perl (used for windows to run program)
    my $pid= fork();
    print "after the fork call the pid = $pid\n";
    if($pid ==0){
    print "I am the child\n";
    exit;
    }
    else {
    sleep 1;
    print "I am the paent and the child has the pid of $pid\n";
    exit;
    }

    (PIPE PROGRAM) (for server)

    #!/usr/bin/perl (used for windows to run program)
    pipe READHANDLE,WRITEHANDLE;
    my $pid = fork();
    if($pid==0){
    my $input;
    print "child: I am the child\n";
    close (READHANDLE);
    while (<STDIN>){
    $input=$_;
    print"child: sending $input\n";
    $input= ~ s/Ths/That/;;
    print WRITEHANDLE $input;
    exit;
    }
    else {
    my $input;
    print "parent: I am the paent and the child has the pid of $pid\n";
    close(WRITEHANDLE);
    $input= <READHNDLE>;
    print "parent: read $input\n;
    exit;
    }


    ////////////////////


    according to this teacher to connect the program to the server i should only have to include the following commands of which i don't know where to put:


    Writing to and from a server:

    require "mainfile.pl";

    unlink ("myfifo.srv");
    unlink("myfifo.srv");
    system('mknod', "myfifo.srv", 'p;');
    system('mknod', "myfifo.clt", 'p');
    close(0);
    open(WRITEHANDLE1, "> myfifo.clt;
    open (READHANDLE1, "> myfifo.srv");
    server (READHANDLE1
    close (READHANDLE1
    close(WRITEHANDLE
    print "server



    FINALLY I AM SUPOSED TO MAKE THE ABOVE HOMEWORK PROGRAM #1, CONNECT TO THE SERVER AND RUN, THEN I NEED TO MAKE IT WORK WITH PIPES, FIFO'S, UDP SOCKETS, AND TCP SOCKETS. I am giving all that he gave us on the homework information just hoping that you can HELP me to make sense of it and maybe finish this homework. I am willing to put in the time to finish the homework, i just am really stuck right now. Thanks for your help in advance.

    Sedric

  2. #2
    Join Date
    Jan 2005
    Location
    UK
    Posts
    604
    Hi Cedric,
    I guess you are on the wrong forum here. The code you quoted is actually perl-script.
    I suggest you post on a relevant forum. Or do you want to translate the code into a C/C++ equivalent?

    Rgds,
    D
    DKyb
    -------------------------------
    Life is a short warm moment -
    Death is the long cold rest.
    Pink Floyd
    -------------------------------

  3. #3
    Join Date
    Nov 2006
    Posts
    3
    I would like to translate it to C code because i understand it better. Or i would like a little help understanding perl code. I haven't worked with perl before. but i have spent time with C code.

    Thanks

    Sedric

Similar Threads

  1. connecting to exchange server 2003 from vb.net
    By vasanthya_then in forum .NET
    Replies: 1
    Last Post: 04-17-2009, 05:15 AM
  2. Help with Server program
    By sedricbenson@ho in forum C++
    Replies: 2
    Last Post: 11-07-2006, 09:18 AM
  3. Replies: 2
    Last Post: 09-11-2006, 12:22 PM
  4. Replies: 2
    Last Post: 03-05-2001, 03:55 PM
  5. Remove exchange from a site
    By andriano in forum Enterprise
    Replies: 1
    Last Post: 10-02-2000, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center