Standard network method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bonj

    Standard network method

    Hi
    I'd like a way of communicating over a network that doesn't rely on
    vendor-specific libraries, preferably that will work on both windows and
    linux (the ideal solution would be one that compiles on windows and linux,
    but the absolute ideal one would be one that also enables windows to
    communicate *with* linux in realtime, but that's a pipe dream as yet...)
    Nothing too fancy, the amounts of data won't be great. Just open a
    connection on a specific port, send some data down it, close. And receive
    from the other end.

    i.e. is there a standard library function for it...? I'm thinking along the
    lines of fopen(), fread(), ..... , is there an f_tcp() ?

    Can be either in C or C++.


  • Florian Quetting

    #2
    Re: Standard network method

    use (TCP-)sockets.

    Bonj wrote:
    [color=blue]
    > Hi
    > I'd like a way of communicating over a network that doesn't rely on
    > vendor-specific libraries, preferably that will work on both windows and
    > linux (the ideal solution would be one that compiles on windows and linux,
    > but the absolute ideal one would be one that also enables windows to
    > communicate *with* linux in realtime, but that's a pipe dream as yet...)
    > Nothing too fancy, the amounts of data won't be great. Just open a
    > connection on a specific port, send some data down it, close. And receive
    > from the other end.
    >
    > i.e. is there a standard library function for it...? I'm thinking along
    > the lines of fopen(), fread(), ..... , is there an f_tcp() ?
    >
    > Can be either in C or C++.[/color]

    Comment

    • Flash Gordon

      #3
      Re: Standard network method

      Bonj wrote:[color=blue]
      > Hi
      > I'd like a way of communicating over a network that doesn't rely on
      > vendor-specific libraries,[/color]

      Then you have a problem.
      [color=blue]
      > preferably that will work on both windows and
      > linux (the ideal solution would be one that compiles on windows and linux,
      > but the absolute ideal one would be one that also enables windows to
      > communicate *with* linux in realtime, but that's a pipe dream as yet...)
      > Nothing too fancy, the amounts of data won't be great. Just open a
      > connection on a specific port, send some data down it, close. And receive
      > from the other end.
      >
      > i.e. is there a standard library function for it...? I'm thinking along the
      > lines of fopen(), fread(), ..... , is there an f_tcp() ?
      >
      > Can be either in C or C++.[/color]

      Nothing like that exists in C. You either need to find a third party
      library ported to all the systems you are interested in or write your own.

      <OT>
      There is a lot of commonality between Windows and *nix, since MS based
      their TCP/IP library on BSD Sockets. So writing some thin wrappers is
      not that difficult. However, how you do networking is not on topic here,
      so ask for details in networking and/or system specific groups.
      </OT>

      Any C++ answers are off topic in comp.lang.c, so please take it off if
      posting a C++ answer.
      --
      Flash Gordon
      Living in interesting times.
      Although my email address says spam, it is real and I read it.

      Comment

      • Dave O'Hearn

        #4
        Re: Standard network method

        Bonj wrote:[color=blue]
        > i.e. is there a standard library function for it...? I'm thinking[/color]
        along[color=blue]
        > the lines of fopen(), fread(), ..... , is there an f_tcp() ?
        >
        > Can be either in C or C++.[/color]

        There is no standard library support for sockets in either C or C++.
        Boost does not support sockets yet either.

        There are some sockets libraries that claim to be portable to many
        platforms, but they are not standard.

        --
        Dave O'Hearn

        Comment

        • Emmanuel Delahaye

          #5
          Re: Standard network method

          Bonj wrote on 31/12/04 :[color=blue]
          > I'd like a way of communicating over a network that doesn't rely on[/color]

          You are completely off-topic ont both newsgroups.
          [color=blue]
          > vendor-specific libraries,[/color]

          Write your own.
          [color=blue]
          > preferably that will work on both windows and
          > linux (the ideal solution would be one that compiles on windows and linux,[/color]

          BSD Sockets and Winsock2 are very similar.
          [color=blue]
          > but the absolute ideal one would be one that also enables windows to
          > communicate *with* linux in realtime, but that's a pipe dream as yet...)[/color]

          There is no reason for a network (IP, for example) not to support
          mac+linux+windo ws or anyelse servers/clients... Zillions of working
          solutions are running around the world probably for a 10th of years...
          [color=blue]
          > Nothing too fancy, the amounts of data won't be great. Just open a connection
          > on a specific port, send some data down it, close. And receive from the other
          > end.
          >
          > i.e. is there a standard library function for it...? I'm thinking along the
          > lines of fopen(), fread(), ..... , is there an f_tcp() ?[/color]

          No. I think there is a kind of a portable wrapper for networking, but I
          can't recall the name. Search the net. Google is your friend.

          --
          Emmanuel
          The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
          The C-library: http://www.dinkumware.com/refxc.html

          "Clearly your code does not meet the original spec."
          "You are sentenced to 30 lashes with a wet noodle."
          -- Jerry Coffin in a.l.c.c++

          Comment

          • Kenny McCormack

            #6
            Re: Standard network method

            In article <1104514223.592 280.134570@c13g 2000cwb.googleg roups.com>,
            Dave O'Hearn <daveoh77@pobox .com> wrote:[color=blue]
            >Bonj wrote:[color=green]
            >> i.e. is there a standard library function for it...? I'm thinking
            >>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
            >>
            >> Can be either in C or C++.[/color]
            >
            >There is no standard library support for sockets in either C or C++.
            >Boost does not support sockets yet either.[/color]

            What is "Boost" ?

            Comment

            • Artie Gold

              #7
              Re: Standard network method

              Kenny McCormack wrote:[color=blue]
              > In article <1104514223.592 280.134570@c13g 2000cwb.googleg roups.com>,
              > Dave O'Hearn <daveoh77@pobox .com> wrote:
              >[color=green]
              >>Bonj wrote:
              >>[color=darkred]
              >>>i.e. is there a standard library function for it...? I'm thinking
              >>>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
              >>>
              >>>Can be either in C or C++.[/color]
              >>
              >>There is no standard library support for sockets in either C or C++.
              >>Boost does not support sockets yet either.[/color]
              >
              >
              > What is "Boost" ?
              >[/color]
              See http://www.boost.org (it's a collection of C++ libraries).

              HTH,
              --ag

              Remember, GIYF!!

              --
              Artie Gold -- Austin, Texas
              http://it-matters.blogspot.com (new post 12/5)

              Comment

              • Emmanuel Delahaye

                #8
                Re: Standard network method

                Kenny McCormack wrote on 31/12/04 :[color=blue]
                > What is "Boost" ?[/color]

                A C++ thing...

                --
                Emmanuel
                The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
                The C-library: http://www.dinkumware.com/refxc.html

                "C is a sharp tool"

                Comment

                • adbarnet

                  #9
                  Re: Standard network method

                  The past inherited, the future encapsulated.

                  "Kenny McCormack" <gazelle@yin.in teraccess.com> wrote in message
                  news:cr48v0$7uu $1@yin.interacc ess.com...[color=blue]
                  > In article <1104514223.592 280.134570@c13g 2000cwb.googleg roups.com>,
                  > Dave O'Hearn <daveoh77@pobox .com> wrote:[color=green]
                  >>Bonj wrote:[color=darkred]
                  >>> i.e. is there a standard library function for it...? I'm thinking
                  >>>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
                  >>>
                  >>> Can be either in C or C++.[/color]
                  >>
                  >>There is no standard library support for sockets in either C or C++.
                  >>Boost does not support sockets yet either.[/color]
                  >
                  > What is "Boost" ?
                  >[/color]


                  Comment

                  • Mike Wahler

                    #10
                    Re: Standard network method

                    "Kenny McCormack" <gazelle@yin.in teraccess.com> wrote in message
                    news:cr48v0$7uu $1@yin.interacc ess.com...[color=blue]
                    > In article <1104514223.592 280.134570@c13g 2000cwb.googleg roups.com>,
                    > Dave O'Hearn <daveoh77@pobox .com> wrote:[color=green]
                    > >Bonj wrote:[color=darkred]
                    > >> i.e. is there a standard library function for it...? I'm thinking
                    > >>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
                    > >>
                    > >> Can be either in C or C++.[/color]
                    > >
                    > >There is no standard library support for sockets in either C or C++.
                    > >Boost does not support sockets yet either.[/color]
                    >
                    > What is "Boost" ?[/color]

                    It's a library of utilities for C++, much of which
                    is slated to be included in the next revision of
                    the standard.

                    See www.boost.org

                    -Mike


                    Comment

                    • adbarnet

                      #11
                      Re: Standard network method

                      BTW please do not top-post

                      AD ;-)

                      "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message
                      news:Q3jBd.1361 8$RH4.525@newsr ead1.news.pas.e arthlink.net...[color=blue]
                      > "Kenny McCormack" <gazelle@yin.in teraccess.com> wrote in message
                      > news:cr48v0$7uu $1@yin.interacc ess.com...[color=green]
                      >> In article <1104514223.592 280.134570@c13g 2000cwb.googleg roups.com>,
                      >> Dave O'Hearn <daveoh77@pobox .com> wrote:[color=darkred]
                      >> >Bonj wrote:
                      >> >> i.e. is there a standard library function for it...? I'm thinking
                      >> >>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
                      >> >>
                      >> >> Can be either in C or C++.
                      >> >
                      >> >There is no standard library support for sockets in either C or C++.
                      >> >Boost does not support sockets yet either.[/color]
                      >>
                      >> What is "Boost" ?[/color]
                      >
                      > It's a library of utilities for C++, much of which
                      > is slated to be included in the next revision of
                      > the standard.
                      >
                      > See www.boost.org
                      >
                      > -Mike
                      >
                      >[/color]


                      Comment

                      • kan Pu

                        #12
                        Re: Standard network method

                        I am not sure what you mean. But a TCP/IP protocol can meet your
                        requirement. And by the way, I think a open source library "ACE" ( Adaptive
                        communication envirement), which can be found in www.cs.wustl.edu/~schmidt/
                        , can be used directly.

                        "Bonj" <a@b.com> дÈëÓʼþ news:33ldpoF3u7 dn5U1@individua l.net...[color=blue]
                        > Hi
                        > I'd like a way of communicating over a network that doesn't rely on
                        > vendor-specific libraries, preferably that will work on both windows and
                        > linux (the ideal solution would be one that compiles on windows and linux,
                        > but the absolute ideal one would be one that also enables windows to
                        > communicate *with* linux in realtime, but that's a pipe dream as yet...)
                        > Nothing too fancy, the amounts of data won't be great. Just open a
                        > connection on a specific port, send some data down it, close. And receive
                        > from the other end.
                        >
                        > i.e. is there a standard library function for it...? I'm thinking along[/color]
                        the[color=blue]
                        > lines of fopen(), fread(), ..... , is there an f_tcp() ?
                        >
                        > Can be either in C or C++.
                        >
                        >[/color]


                        Comment

                        • Bonj

                          #13
                          Re: Standard network method


                          "Emmanuel Delahaye" <emdel@YOURBRAn oos.fr> wrote in message
                          news:mn.fc9e7d4 c74d67530.15512 @YOURBRAnoos.fr ...[color=blue]
                          > Bonj wrote on 31/12/04 :[color=green]
                          >> I'd like a way of communicating over a network that doesn't rely on[/color]
                          >
                          > You are completely off-topic ont both newsgroups.[/color]

                          So what's the correct newsgroup to post requesting something in C, that
                          works on windows and linux then?
                          [color=blue]
                          > Write your own.[/color]

                          Where do I start?


                          Comment

                          • Gernot Frisch

                            #14
                            Re: Standard network method


                            "Bonj" <a@b.com> schrieb im Newsbeitrag
                            news:33ldpoF3u7 dn5U1@individua l.net...[color=blue]
                            > Hi
                            > I'd like a way of communicating over a network that doesn't rely on
                            > vendor-specific libraries, preferably that will work on both windows
                            > and linux (the ideal solution would be one that compiles on windows
                            > and linux, but the absolute ideal one would be one that also enables
                            > windows to communicate *with* linux in realtime, but that's a pipe
                            > dream as yet...)
                            > Nothing too fancy, the amounts of data won't be great. Just open a
                            > connection on a specific port, send some data down it, close. And
                            > receive from the other end.
                            >
                            > i.e. is there a standard library function for it...? I'm thinking
                            > along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
                            >
                            > Can be either in C or C++.[/color]

                            You can download the source code for HawkNL - a cross platform
                            networking library - based on socks:

                            I think it's very good, though it's not maintained much anymore I
                            think.

                            also, from Alex Vinokur:
                            C++ Stram Compatible TCP/IP Sockets:
                            Download C++ Stream Compatible TCP/IP Sockets for free. The program implements a demo application which demonstrates using C++ stream-compatible sockets developed by Maciej Sobczak http://www.msobczak.com/



                            HTH,
                            Gernot


                            Comment

                            • infobahn

                              #15
                              Re: Standard network method

                              Bonj wrote:[color=blue]
                              >
                              > "Emmanuel Delahaye" <emdel@YOURBRAn oos.fr> wrote in message
                              > news:mn.fc9e7d4 c74d67530.15512 @YOURBRAnoos.fr ...[color=green]
                              > > Bonj wrote on 31/12/04 :[color=darkred]
                              > >> I'd like a way of communicating over a network that doesn't rely on[/color]
                              > >
                              > > You are completely off-topic ont both newsgroups.[/color]
                              >
                              > So what's the correct newsgroup to post requesting something in C, that
                              > works on windows and linux then?[/color]

                              comp.lang.c is the right place to ask questions about portable C
                              programming. Unfortunately, network programming can't be done in
                              a way that is sufficiently portable to justify its discussion in
                              comp.lang.c. Nevertheless, your second question (below) is
                              topical, in my opinion, so I'll try to answer it.
                              [color=blue]
                              >[color=green]
                              > > Write your own.[/color]
                              >
                              > Where do I start?[/color]

                              Begin by learning how to write networking programs in Linux,
                              if you don't already know how to do this.

                              Continue by learning how to write networking programs in
                              Windows, if you don't already know how to do this.

                              Finally, abstract the non-portable parts of your programs
                              into a library, in such a way that you can keep your
                              application portable. Think of your library as a layer
                              between your application and the OS-specific aspects
                              of networking.

                              For example, under Windows, you need to start the
                              networking interface using an OS-specific call. Under
                              Linux, you don't. So you could write a routine
                              something like this:

                              /* start_networkin g() - Windows version */
                              int start_networkin g(P p)
                              {
                              /* insert Windows networking startup code here */

                              return 0 if it worked, or a non-zero value otherwise.
                              }

                              /* start_networkin g() - Linux version */
                              int start_networkin g(P p)
                              {
                              return 0;
                              }

                              In your .lib, you'll use the first version. In
                              your .a or .so, you'll use the second. In both
                              cases, your application code will look something
                              like this:

                              int got_a_network = start_networkin g(params);
                              if(got_a_networ k)
                              {
                              do stuff here
                              }

                              C++ fans might have a different way of doing
                              this, but this way will work in both languages.

                              The point is that, whilst the body of the
                              library routines will differ across platforms,
                              the interface stays the same, which means that
                              your application code itself need not change.

                              It's not trivial, but it's not rocket science either.

                              Comment

                              Working...