Passing parameters to an executable vs. passing them to a server

Discussion in 'C++' started by Ramon F Herrera, Sep 12, 2009.

  1. The only method that I have ever used to pass parameters to a program
    is the good 'ole trusted:

    main(int argc, char *argv[])

    As of late, however, I began writing servers (more like "borrowing"
    their code from the net :), and I am not familiar with the method
    used to pass arguments to them.

    The specific server program that I modified is this one:

    http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime2/src.html

    It is a "daytime" server, which does not accept any arguments.

    TIA,

    -Ramon
     
    Ramon F Herrera, Sep 12, 2009
    #1
    1. Advertising

  2. On Sep 11, 11:45 pm, Ramon F Herrera <> wrote:
    > The only method that I have ever used to pass parameters to a program
    > is the good 'ole trusted:
    >
    > main(int argc, char *argv[])
    >
    > As of late, however, I began writing servers (more like "borrowing"
    > their code from the net :), and I am not familiar with the method
    > used to pass arguments to them.
    >
    > The specific server program that I modified is this one:
    >
    > http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tut...
    >
    > It is a "daytime" server, which does not accept any arguments.
    >
    > TIA,
    >
    > -Ramon


    Never mind!!!

    -Ramon
     
    Ramon F Herrera, Sep 12, 2009
    #2
    1. Advertising

  3. Ramon F Herrera

    Ian Collins Guest

    Ramon F Herrera wrote:

    Please restrict your cross-posting!

    --
    Ian Collins
     
    Ian Collins, Sep 12, 2009
    #3
  4. On Sep 11, 11:53 pm, Ian Collins <> wrote:
    > Ramon F Herrera wrote:
    >
    > Please restrict your cross-posting!
    >
    > --
    > Ian Collins


    Ian,

    I don't mean to be rude, but...

    Google News allows 5 newsgroups.

    The creators of Usenet designed the ability to cross-post.

    Take your issue with them.

    The 3 newsgroup I posted to are pertinent.

    What are your trying to save? Disk space?

    Have you noticed the spam crap that Usenet has become?

    Every time a legitimate article (like mine) is posted, it scrolls down
    the spam.

    -Ramon
     
    Ramon F Herrera, Sep 12, 2009
    #4
  5. On Sep 11, 11:45 pm, Ramon F Herrera <> wrote:
    > The only method that I have ever used to pass parameters to a program
    > is the good 'ole trusted:
    >
    > main(int argc, char *argv[])
    >
    > As of late, however, I began writing servers (more like "borrowing"
    > their code from the net :), and I am not familiar with the method
    > used to pass arguments to them.
    >
    > The specific server program that I modified is this one:
    >
    > http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tut...
    >
    > It is a "daytime" server, which does not accept any arguments.
    >
    > TIA,
    >
    > -Ramon



    I was looking at this echo server:

    http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/echo/blocking_tcp_echo_client.cpp

    and it looks like it is up to the coder to package the arguments on
    the clients and break them down in the server?

    Perhaps I need to construct the arguments like this?:

    string arguments = "arg1 = this; arg2 = that; arg3 = whatever";

    TIA,

    -Ramon
     
    Ramon F Herrera, Sep 12, 2009
    #5
  6. Ramon F Herrera

    Ian Collins Guest

    Ramon F Herrera wrote:
    > On Sep 11, 11:53 pm, Ian Collins <> wrote:
    >> Ramon F Herrera wrote:
    >>
    >> Please restrict your cross-posting!
    >>

    >
    > Ian,
    >
    > I don't mean to be rude, but...
    >
    > Google News allows 5 newsgroups.
    >
    > The creators of Usenet designed the ability to cross-post.
    >
    > Take your issue with them.
    >
    > The 3 newsgroup I posted to are pertinent.


    If you have a C++ language question, use c.l.c++, a Unix specific one,
    c.l.p and use c.p for non-specific programming questions. This one
    looks like a C++ question.

    > Have you noticed the spam crap that Usenet has become?


    No, I use a decent server and client.

    --
    Ian Collins
     
    Ian Collins, Sep 12, 2009
    #6
  7. Ramon F Herrera

    Ian Collins Guest

    Ramon F Herrera wrote:
    > On Sep 11, 11:45 pm, Ramon F Herrera <> wrote:
    >> The only method that I have ever used to pass parameters to a program
    >> is the good 'ole trusted:
    >>
    >> main(int argc, char *argv[])
    >>
    >> As of late, however, I began writing servers (more like "borrowing"
    >> their code from the net :), and I am not familiar with the method
    >> used to pass arguments to them.
    >>
    >> The specific server program that I modified is this one:
    >>
    >> http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tut...
    >>
    >> It is a "daytime" server, which does not accept any arguments.
    >>
    >> TIA,
    >>
    >> -Ramon

    >
    >
    > I was looking at this echo server:
    >
    > http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/echo/blocking_tcp_echo_client.cpp
    >
    > and it looks like it is up to the coder to package the arguments on
    > the clients and break them down in the server?


    Eh? it uses argv[n] just like any other C++ application.

    --
    Ian Collins
     
    Ian Collins, Sep 12, 2009
    #7
  8. On Sep 12, 1:18 am, Ian Collins <> wrote:
    > Ramon F Herrera wrote:
    > > On Sep 11, 11:45 pm, Ramon F Herrera <> wrote:
    > >> The only method that I have ever used to pass parameters to a program
    > >> is the good 'ole trusted:

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

    >
    > >> As of late, however, I began writing servers (more like "borrowing"
    > >> their code from the net :), and I am not familiar with the method
    > >> used to pass arguments to them.

    >
    > >> The specific server program that I modified is this one:

    >
    > >>http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tut....

    >
    > >> It is a "daytime" server, which does not accept any arguments.

    >
    > >> TIA,

    >
    > >> -Ramon

    >
    > > I was looking at this echo server:

    >
    > >http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/echo...

    >
    > > and it looks like it is up to the coder to package the arguments on
    > > the clients and break them down in the server?

    >
    > Eh?  it uses argv[n] just like any other C++ application.
    >
    > --
    > Ian Collins



    Thanks, Ian.

    I got confused about for a little while.

    The problem is that a server has to receive arguments twice:

    (1) When it first starts up, in the classical way (argv[]).

    (2) When it is running, it gets connections from clients which need
    to pass to it a different set of parameters.

    The part that I am investigating is the second.

    I am currently reading the code of this http client. See snippet
    below.

    http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/http/client/sync_client.cpp

    Thx,

    -Ramon

    ----------------------

    // Form the request. We specify the "Connection: close" header so
    that the
    // server will close the socket after transmitting the response.
    This will
    // allow us to treat all data up until the EOF as the content.
    boost::asio::streambuf request;
    std::eek:stream request_stream(&request);
    request_stream << "GET " << argv[2] << " HTTP/1.0\r\n";
    request_stream << "Host: " << argv[1] << "\r\n";
    request_stream << "Accept: */*\r\n";
    request_stream << "Connection: close\r\n\r\n";

    // Send the request.
    boost::asio::write(socket, request);
     
    Ramon F Herrera, Sep 12, 2009
    #8
  9. Ramon F Herrera <> writes:
    > I was looking at this echo server:

    _____________________________^^^^^^

    > http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/echo/blocking_tcp_echo_client.cpp

    __________________________________________________________________________________________^^^^^^



    You are inconsistent. How do you expect us to answer meaningfully
    inconsistent questions?


    > and it looks like it is up to the coder to package the arguments on
    > the clients and break them down in the server?


    What are you talking about?


    --
    __Pascal Bourguignon__
     
    Pascal J. Bourguignon, Sep 13, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul D. Fox
    Replies:
    1
    Views:
    14,213
  2. Anonieko

    HttpHandlers - Learn Them. Use Them.

    Anonieko, Jun 15, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    520
    tdavisjr
    Jun 16, 2006
  3. Replies:
    15
    Views:
    491
    Dave Thompson
    Aug 21, 2006
  4. ramata
    Replies:
    1
    Views:
    187
    Ray Costanzo [MVP]
    May 6, 2005
  5. why the lucky stiff
    Replies:
    5
    Views:
    146
    why the lucky stiff
    Sep 22, 2004
Loading...

Share This Page