Re: High-level network programming: is C language suitable for that?

Discussion in 'C Programming' started by Jens Thoms Toerring, Apr 26, 2012.

  1. pozz <> wrote:
    > I'll start a new application in a short time and I'm wondering if C
    > language is good enough for that.


    > The application will be simple: it should implement some TCP/UDP
    > protocols (like TFTP, BOOTP,...) with a simple GUI. It will run on
    > Windows platforms, but the possibility to run it on Linux would be nice.


    > Is C language suitable for this kind of applications? Which kind of
    > cross-platform libraries should I use to manage IP protocols and simple
    > GUIs? Could python or other high-level (script) languages be a better
    > choice?


    Of course, all this can be done in C (most scripting languages
    are actually implemented in C, so everything you can do in
    those languages can obviously be done in C). But note that C
    has no "native" support for networking or graphics, thus the
    need for additional (cross-platform) libraries (unless you're
    keen to re-invent the wheel;-). For TFTP and other protocols
    libcurl seems to be a candidate to take a look at. I don't
    know about BOOTP (wasn't that obsoleted by DHCP?). For gra-
    phics the only cross-platform library for C I know about is
    GTK+ (but I never used it) - most other seem to require C++.

    If using Python or some other scripting language would be pre-
    ferable depends on what you want to do there, if you need max-
    imum performance, and if you feel comfortable with that lan-
    guage. Perhaps it might be a good idea to start with a scrip-
    ting language and see if it does ok, otherwise you can still
    re-implement the stuff in C, drawing on the experiences you
    made.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Apr 26, 2012
    #1
    1. Advertising

  2. Jens Thoms Toerring

    BartC Guest

    "Jens Thoms Toerring" <> wrote in message
    news:-berlin.de...
    > pozz <> wrote:
    >> I'll start a new application in a short time and I'm wondering if C
    >> language is good enough for that.


    > Of course, all this can be done in C (most scripting languages
    > are actually implemented in C, so everything you can do in
    > those languages can obviously be done in C).


    By that argument, it can all be done in machine code or assembler too.

    C *can* program just about anything, but it can be a lot easier and less
    error-prone to just use a higher-level, more adept language.

    --
    Bartc
    BartC, Apr 27, 2012
    #2
    1. Advertising

  3. Jens Thoms Toerring

    Guest

    Il giorno giovedì 26 aprile 2012 21:54:40 UTC+2, Jens Thoms Toerring ha scritto:
    > pozz
    > wrote:
    > > I'll start a new application in a short time and I'm wondering if C
    > > language is good enough for that.

    >
    > > The application will be simple: it should implement some TCP/UDP
    > > protocols (like TFTP, BOOTP,...) with a simple GUI. It will run on
    > > Windows platforms, but the possibility to run it on Linux would be nice..

    >
    > > Is C language suitable for this kind of applications? Which kind of
    > > cross-platform libraries should I use to manage IP protocols and simple
    > > GUIs? Could python or other high-level (script) languages be a better
    > > choice?

    >
    > Of course, all this can be done in C (most scripting languages
    > are actually implemented in C, so everything you can do in
    > those languages can obviously be done in C).


    Oh, yes. I know C is powerful enough to manage comple network
    protocols and beautiful graphical interfaces. The questions was
    related to a simple application where I don't want to loose
    too much time to find a suitable network and graphic library and
    fine tune them. C can do anything at the cost of greater complexity.

    I'm asking if a high-level scripting language can be more effective
    for simple tasks and applications.


    > But note that C
    > has no "native" support for networking or graphics, thus the
    > need for additional (cross-platform) libraries (unless you're
    > keen to re-invent the wheel;-).


    Absolutely no, I want to reuse existing libraries.


    > For TFTP and other protocols
    > libcurl seems to be a candidate to take a look at. I don't
    > know about BOOTP (wasn't that obsoleted by DHCP?).


    I have to implement a sub-set of DHCP protocol, similar to the
    original BOOTP. It's for an Ethernet firmware upgrade for
    and embedded gadget.


    > For gra-
    > phics the only cross-platform library for C I know about is
    > GTK+ (but I never used it) - most other seem to require C++.
    >
    > If using Python or some other scripting language would be pre-
    > ferable depends on what you want to do there, if you need max-
    > imum performance, and if you feel comfortable with that lan-
    > guage. Perhaps it might be a good idea to start with a scrip-
    > ting language and see if it does ok, otherwise you can still
    > re-implement the stuff in C, drawing on the experiences you
    > made.


    Ok, thank you for your suggestions.
    , Apr 27, 2012
    #3
  4. Jens Thoms Toerring

    Guest

    On Thursday, April 26, 2012 8:54:40 PM UTC+1, Jens Thoms Toerring wrote:
    > pozz wrote:


    > > I'll start a new application in a short time and I'm wondering if C
    > > language is good enough for that.


    C's pretty much "good enough" for anything. Could you produce your application quicker using some other language? Maybe.

    > > The application will be simple: it should implement some TCP/UDP
    > > protocols (like TFTP, BOOTP,...) with a simple GUI. It will run on
    > > Windows platforms, but the possibility to run it on Linux would be nice..

    >
    > > Is C language suitable for this kind of applications? Which kind of
    > > cross-platform libraries should I use to manage IP protocols and simple
    > > GUIs? Could python or other high-level (script) languages be a better
    > > choice?


    python is certainly worth a look. It comes "out of the box" with socket andGUI libraries. It'll also run on multiple platforms, probably without change. Python can be a bit slow (which may not matter).

    > Of course, all this can be done in C (most scripting languages
    > are actually implemented in C, so everything you can do in
    > those languages can obviously be done in C).


    this is a theoretically true but practically useless.

    *All* real-world programming languages are "turing complete". Which (loosly) means if it can be programmed then it can be programmed in that language.We could implement python in COBOL (if we enjoyed kicking dead whales downbeaches) but it wouldn't be fun.

    > But note that C
    > has no "native" support for networking or graphics, thus the
    > need for additional (cross-platform) libraries (unless you're
    > keen to re-invent the wheel;-). For TFTP and other protocols
    > libcurl seems to be a candidate to take a look at. I don't
    > know about BOOTP (wasn't that obsoleted by DHCP?). For gra-
    > phics the only cross-platform library for C I know about is
    > GTK+ (but I never used it) - most other seem to require C++.


    openGL, Qt

    > If using Python or some other scripting language would be pre-
    > ferable depends on what you want to do there, if you need max-
    > imum performance, and if you feel comfortable with that lan-
    > guage. Perhaps it might be a good idea to start with a scrip-
    > ting language and see if it does ok, otherwise you can still
    > re-implement the stuff in C, drawing on the experiences you
    > made.


    yes that is a good idea. You may get something working much quicker in Python.
    , Apr 27, 2012
    #4
  5. wrote:
    > On Thursday, April 26, 2012 8:54:40 PM UTC+1, Jens Thoms Toerring wrote:
    > > Of course, all this can be done in C (most scripting languages
    > > are actually implemented in C, so everything you can do in
    > > those languages can obviously be done in C).


    > this is a theoretically true but practically useless.


    Well, the OP was asking "if C language is good enough for that";-)

    > > But note that C
    > > has no "native" support for networking or graphics, thus the
    > > need for additional (cross-platform) libraries (unless you're
    > > keen to re-invent the wheel;-). For TFTP and other protocols
    > > libcurl seems to be a candidate to take a look at. I don't
    > > know about BOOTP (wasn't that obsoleted by DHCP?). For gra-
    > > phics the only cross-platform library for C I know about is
    > > GTK+ (but I never used it) - most other seem to require C++.


    > openGL, Qt


    I fear using OpenGL for a simple GUI might not be too
    suitable since it's a rendering library and what you
    want for most simple GUIs is a set of widgets you can
    easily manipulate, which isn't what OpenGL meant for
    if I didn't mis-understand its purpose. Qt is defini-
    tely C++ and I guess it could be a real pain if one
    would try to marry it to a C program...

    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Apr 27, 2012
    #5
  6. Jens Thoms Toerring

    Rui Maciel Guest

    Jens Thoms Toerring wrote:

    > But note that C
    > has no "native" support for networking or graphics, thus the
    > need for additional (cross-platform) libraries (unless you're
    > keen to re-invent the wheel;-).


    That depends on what's your definition of "native" support. There is a
    considerable number of graphics and networking libraries which provide a C
    API and are extensively used. For example, OpenGL, POSIX sockets and GTK
    come to mind.


    Rui Maciel
    Rui Maciel, Apr 27, 2012
    #6
  7. Rui Maciel <> wrote:
    > Jens Thoms Toerring wrote:
    > > But note that C
    > > has no "native" support for networking or graphics, thus the
    > > need for additional (cross-platform) libraries (unless you're
    > > keen to re-invent the wheel;-).


    > That depends on what's your definition of "native" support.


    I would consider to be "native support" everything that comes
    with the C standard library. Everything else is, at least for
    me, optional - it might exist but doesn't have to. In other
    languages (Java, Python) this is part of the core language
    (if that was a brilliant idea will be clearer in let's say
    20 years from now;-).

    > There is a considerable number of graphics and networking libraries
    > which provide a C API and are extensively used. For example, OpenGL,
    > POSIX sockets and GTK come to mind.


    That's just what, in the rest of my post, I thought I had
    mentioned;-) Though I wouldn't consider OpenGL to be a GUI
    library ("simple GUI" doesn't evoke the association of "fast
    3D rendering" for me but more "a few buttons and maybe a few
    other useful widgets"). And I don't know, not being a Windows
    programmer, how far the POSIX socket API is supported under
    Windows, the OPs primary target - and my impression was any-
    way that he wanted something more "high-level", that's why I
    mentioned libcurl as something to consider for (at least) part
    of his task.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Apr 27, 2012
    #7
  8. בת×ריך ×™×•× ×©×™×©×™, 27 ב×פריל 2012 23:37:41 UTC+1, מ×ת Jens Thoms Toerring:
    >
    > That's just what, in the rest of my post, I thought I had
    > mentioned;-) Though I wouldn't consider OpenGL to be a GUI
    > library ("simple GUI" doesn't evoke the association of "fast
    > 3D rendering" for me but more "a few buttons and maybe a few
    > other useful widgets").
    >

    Open GL is a graphics library that mainly emphasises 3D rendering. However you seldom want an application that consists purely of a window containing a 3D scene. Open GL has a few 2D functions that allow you to add GUI type components on top of a window. The problem is you've got to write everythingfrom scratch, such as the code to add the highlight and lowlight to your buttons. That tends not to matter so much for games, where you want the GUI to have a customised, fun look and feel. But for serious applications you want the reverse, the same look and feel as the desktop. So the Open GL route isn't a good one.
    Malcolm McLean, Apr 28, 2012
    #8
  9. Jens Thoms Toerring

    Guest

    On Friday, April 27, 2012 4:07:38 PM UTC+1, pozz wrote:
    > Il 27/04/2012 16:27, nick_keighley ha scritto:
    > [...]
    > >> For gra-
    > >> phics the only cross-platform library for C I know about is
    > >> GTK+ (but I never used it) - most other seem to require C++.

    > >
    > > openGL, Qt

    >
    > QT? I knew QT was for C++ and not C language.


    quite correct, I misremembered
    , Apr 29, 2012
    #9
  10. Jens Thoms Toerring

    Guest

    On Friday, April 27, 2012 6:07:08 PM UTC+1, Jens Thoms Toerring wrote:
    > wrote:
    > > On Thursday, April 26, 2012 8:54:40 PM UTC+1, Jens Thoms Toerring wrote:


    > > > Of course, all this can be done in C (most scripting languages
    > > > are actually implemented in C, so everything you can do in
    > > > those languages can obviously be done in C).

    >
    > > this is a theoretically true but practically useless.

    >
    > Well, the OP was asking "if C language is good enough for that";-)


    true, but implementing a script langauge before you start implementing the real problem may be an indication you've picked the wrong langauge. Though the Lisp metalinguists may disagree as might Fowler's "Domain Specific Languages"

    > > > But note that C
    > > > has no "native" support for networking or graphics, thus the
    > > > need for additional (cross-platform) libraries (unless you're
    > > > keen to re-invent the wheel;-). For TFTP and other protocols
    > > > libcurl seems to be a candidate to take a look at. I don't
    > > > know about BOOTP (wasn't that obsoleted by DHCP?). For gra-
    > > > phics the only cross-platform library for C I know about is
    > > > GTK+ (but I never used it) - most other seem to require C++.

    >
    > > openGL, Qt

    >
    > I fear using OpenGL for a simple GUI might not be too
    > suitable since it's a rendering library and what you
    > want for most simple GUIs is a set of widgets you can
    > easily manipulate,


    I've used an inhouse GUI tool that was built on top of OpenGL, though of course building that's extemly non-trivial!

    There's GLUT that claims to be a GUI interface

    which isn't what OpenGL meant for
    > if I didn't mis-understand its purpose. Qt is defini-
    > tely C++ and I guess it could be a real pain if one
    > would try to marry it to a C program...
    >
    > Regards, Jens
    > --
    > \ Jens Thoms Toerring ___
    > \__________________________ http://toerring.de




    On Friday, April 27, 2012 6:07:08 PM UTC+1, Jens Thoms Toerring wrote:
    > wrote:
    > > On Thursday, April 26, 2012 8:54:40 PM UTC+1, Jens Thoms Toerring wrote:
    > > > Of course, all this can be done in C (most scripting languages
    > > > are actually implemented in C, so everything you can do in
    > > > those languages can obviously be done in C).

    >
    > > this is a theoretically true but practically useless.

    >
    > Well, the OP was asking "if C language is good enough for that";-)
    >
    > > > But note that C
    > > > has no "native" support for networking or graphics, thus the
    > > > need for additional (cross-platform) libraries (unless you're
    > > > keen to re-invent the wheel;-). For TFTP and other protocols
    > > > libcurl seems to be a candidate to take a look at. I don't
    > > > know about BOOTP (wasn't that obsoleted by DHCP?). For gra-
    > > > phics the only cross-platform library for C I know about is
    > > > GTK+ (but I never used it) - most other seem to require C++.

    >
    > > openGL, Qt

    >
    > I fear using OpenGL for a simple GUI might not be too
    > suitable since it's a rendering library and what you
    > want for most simple GUIs is a set of widgets you can
    > easily manipulate, which isn't what OpenGL meant for
    > if I didn't mis-understand its purpose. Qt is defini-
    > tely C++ and I guess it could be a real pain if one
    > would try to marry it to a C program...
    >
    > Regards, Jens
    > --
    > \ Jens Thoms Toerring ___
    > \__________________________ http://toerring.de
    , Apr 29, 2012
    #10
  11. Jens Thoms Toerring

    Guest

    On Friday, April 27, 2012 11:37:41 PM UTC+1, Jens Thoms Toerring wrote:
    > Rui Maciel wrote:
    > > Jens Thoms Toerring wrote:


    <snip>

    > > There is a considerable number of graphics and networking libraries
    > > which provide a C API and are extensively used. For example, OpenGL,
    > > POSIX sockets and GTK come to mind.

    >
    > That's just what, in the rest of my post, I thought I had
    > mentioned;-) Though I wouldn't consider OpenGL to be a GUI
    > library


    no it isn't. GLUT might be though.

    ("simple GUI" doesn't evoke the association of "fast
    > 3D rendering" for me but more "a few buttons and maybe a few
    > other useful widgets").


    does everyone need "fast 3d rendering"? You can write some pretty fancy GUIapplications without it. And he's doing network programming not Halo-N. A few buttons and forms and maybe a histogram or line graph would seem about it for network programming GUI. How complicated can you make BOOTP!

    > And I don't know, not being a Windows
    > programmer, how far the POSIX socket API is supported under
    > Windows, the OPs primary target


    Windows has its own socket interafec that is just slightly different from BSD (and I assume Posix). Just enough to be irritating. A fairly thin wrapper can hide the differences.

    > - and my impression was any-
    > way that he wanted something more "high-level", that's why I
    > mentioned libcurl as something to consider for (at least) part
    > of his task.
    , Apr 29, 2012
    #11
  12. Jens Thoms Toerring

    Robert Miles Guest

    On 4/27/2012 5:37 PM, Jens Thoms Toerring wrote:
    > Rui Maciel<> wrote:
    >> Jens Thoms Toerring wrote:

    [snip]
    >> There is a considerable number of graphics and networking libraries
    >> which provide a C API and are extensively used. For example, OpenGL,
    >> POSIX sockets and GTK come to mind.

    >
    > That's just what, in the rest of my post, I thought I had
    > mentioned;-) Though I wouldn't consider OpenGL to be a GUI
    > library ("simple GUI" doesn't evoke the association of "fast
    > 3D rendering" for me but more "a few buttons and maybe a few
    > other useful widgets"). And I don't know, not being a Windows
    > programmer, how far the POSIX socket API is supported under
    > Windows, the OPs primary target - and my impression was any-
    > way that he wanted something more "high-level", that's why I
    > mentioned libcurl as something to consider for (at least) part
    > of his task.
    > Regards, Jens


    If you want the POSIX socket API under Windows, you might want
    to investigate the Cygwin method of getting a Linux emulation
    under Windows.

    Robert Miles
    Robert Miles, May 29, 2012
    #12
    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. pabbu
    Replies:
    8
    Views:
    720
    Marc Boyer
    Nov 7, 2005
  2. Scorpiion
    Replies:
    1
    Views:
    1,346
    Scorpiion
    Dec 25, 2008
  3. Heinrich Wolf
    Replies:
    0
    Views:
    378
    Heinrich Wolf
    Apr 26, 2012
  4. ImpalerCore
    Replies:
    0
    Views:
    376
    ImpalerCore
    Apr 26, 2012
  5. Malcolm McLean
    Replies:
    1
    Views:
    532
    Rui Maciel
    Apr 27, 2012
Loading...

Share This Page