Thread: C TCP Server Linux

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    2

    C TCP Server Linux

    Hi all,
    I have written a TCP server in C, which will wait for any client to connect and when connected will start streaming data.
    Issue i am facing
    after a sucessful connection with client, if any breach in connection occurs the program exits. and i have to start the program all again
    How can i write the program torun the server continuosly, and restart itself every time the client gets disconnected due to any reason?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    sounds like a good application for a loop. while (1) ought to do it.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Jul 2014
    Posts
    2
    Already implemented an infinite loop.
    Program exits itslef when connection to client in broken.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    maybe if you show your actual code, I could give you more than just speculation.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    One possibility - in Linux servers have to handle the SIGPIPE signal otherwise they can be terminated by a broken client connection. A quick google on SIGPIPE should give you the relevant info.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TCP Server on Linux + boost
    By kargo in forum C++ Programming
    Replies: 6
    Last Post: 06-10-2011, 06:38 PM
  2. Writing a linux server in C
    By robsbots in forum Linux Programming
    Replies: 2
    Last Post: 11-14-2010, 09:37 AM
  3. Client/server in C ( linux )
    By BujarM in forum C Programming
    Replies: 4
    Last Post: 04-19-2009, 03:51 PM
  4. problems with linux UDP server
    By Lopizda in forum Networking/Device Communication
    Replies: 5
    Last Post: 04-26-2007, 08:42 AM
  5. Linux Server
    By Carp in forum C++ Programming
    Replies: 3
    Last Post: 01-24-2003, 02:52 PM