Thread: C socket programming Help!

  1. #1
    Registered User
    Join Date
    May 2006

    C socket programming Help!

    Hello All,

    I want to build a TCP socket function which based on a event application.
    I almost finished all the function except a small problem.

    Here is the problem, The client can connect my application call evtest through port 7046. After the connection is built, the evtest can send out the command string to the client.

    But if the client closes the connection and my evtest will shut down also. It said that "Send, connection reset by peer."

    What I really want my evtest can always active, the client side can always connect to my evtest even after close the connection.

    To more clearly present what I want, I want the evtest application can always accept the outside connection and send out the command to them. Even the client break out connection, they can simply connect to my evtest application without distrub my evtest.

    Thank you for reading. Sorry for my english.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Check out the send man page.

    send() will return -1 when the remote host has closed the connection, and it will set errno to ECONNRESET. If you just check to see if that's what errno is set to when send() returns -1 then you should be able to handle it appropriately.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  2. Socket Help - Multiple Clients
    By project95talon in forum C Programming
    Replies: 5
    Last Post: 11-17-2005, 02:51 AM
  3. when to close a socket
    By Wisefool in forum Networking/Device Communication
    Replies: 5
    Last Post: 11-02-2003, 10:33 AM
  4. problem closing socket
    By Wisefool in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-29-2003, 12:19 PM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM