• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Connection problem I do not understand
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Connection problem I do not understand


  • Subject: Connection problem I do not understand
  • From: Scott Ribe <email@hidden>
  • Date: Thu, 31 May 2007 11:49:16 -0600
  • Resent-date: Thu, 31 May 2007 12:54:39 -0600
  • Resent-from: Scott Ribe <email@hidden>
  • Resent-message-id: <C28466BC.75762%email@hidden>
  • Resent-to: <email@hidden>
  • Thread-topic: Connection problem I do not understand

Situation:

- 1 server
- 30 clients on the same subnet
- 29 clients can connect, 1 client logs ECONNREFUSED (61) in the LogErrorG
line near the end of this code fragment
- pull up Network Utility on that client and port scan the server at the
expected port, it can connect
- server has lots of logging
- when Network Utility port scans I see the log record the whole thing:
kqueue returns the event, it gets the socket and starts reading, it doesn't
get the initial handshake it expects and closes the socket--there is no
noticeable lag between connection attempt at client and server's logging the
new connection
- when application tries to connect, the server log shows no entries
- the application was working, then just quit, server & client reboots
didn't help, after reboot server had no other connections so it's not a
resource limit
- after 36 hours of this, the client again connects
- I tried multiple tests (3x) where client wouldn't connect but Network
Utility could


Here's the client connection code, with error handling removed, and error
logging removed except the single statement that reports ECONNREFUSED. Any
ideas? Was this just some weird transient thing with the network, and
coincidence that Network Utility could connect?

    mSocket = socket( AF_INET, SOCK_STREAM, 0 );
    if( mSocket == -1 )
        err = errno;

    if( !err )
    {
        flags = fcntl( mSocket, F_GETFL, 0 );
        if( flags == -1 )
            err = errno;
    }

    if( !err && fcntl( mSocket, F_SETFL, flags | O_NONBLOCK ) == -1 )
        err = errno;

    if( connect( mSocket, (sockaddr *) &mHostAddress, sizeof mHostAddress )
== -1 )
    {
        if( errno != EINPROGRESS )
            err = errno;
        else
        {
            fd_set rdevts;
            fd_set wrevts;
            FD_ZERO( &rdevts );
            FD_ZERO( &wrevts );
            FD_SET( mSocket, &rdevts );
            FD_SET( mSocket, &wrevts );
            timeval tmout = { 5, 0 };

            switch( select( mSocket + 1, &rdevts, &wrevts, NULL, &tmout ) )
            {
                case -1:
                    err = errno;
                    break;
                case 0:
                    err = ETIMEDOUT;
                    break;
                default:
                    socklen_t errlen = sizeof err;
                    if( getsockopt( mSocket, SOL_SOCKET, SO_ERROR, &err,
&errlen ) == -1 )
                        err = errno;
                    else if( err )
// ****** this is where it reports err is 61
                        LogErrorG( "error (", err, ") on socket after
selecting on connection" );
                    break;
            }
        }
    }

--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Finding a device id through which TCP packet is sent
  • Previous by thread: Re: Finding a device id through which TCP packet is sent
  • Index(es):
    • Date
    • Thread