• 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
send on unconnected socket = crash (TCP sockets on X)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

send on unconnected socket = crash (TCP sockets on X)


  • Subject: send on unconnected socket = crash (TCP sockets on X)
  • From: email@hidden
  • Date: Tue, 9 Jul 2002 17:20:23 -0400

I'm working on a client-server pair and seeing some behavior I don't expect.

The client is a Mach-O Carbon app on Mac OS X 10.1.5, developed in CodeWarrior Pro 8. It calls the Sockets API in the System framework. The server...well, I guess that doesn't matter for this question, except that the machine I'm trying to connect to is running Windows 2000.

The sequence performed by the client is:
Call socket() to get a socket.
Set the socket non-blocking.
Call connect().
Call select() with the socket in the readable and writable sets and NULL for the other set.
Assuming no error is returned from select(), set the socket blocking and then send() some data.

Sometimes I've run this with the client pointed at the wrong server address, or the server not running for one reason or another. What I expected to happen was that connect() would return no error, since it's non-blocking, select() would discover the failed connect and mark the socket as readable and writable, then send() would return -1 and I'd look at errno to find that the socket isn't connected.

What actually happens is that the application crashes inside the send() call. CodeWarrior's debugger reports a non-helpful reason, something like "an unknown exception occurred". I would have thought the only thing I could do wrong to get send() to crash would be to pass it a bad buffer pointer or buffer length so it accesses a memory location it shouldn't, but that's not what's happening.

Is my sequence the right way to handle things? Should send() not crash? Any idea what, if anything, I'm doing wrong?

TIA

Phil Wasson
email@hidden
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: send on unconnected socket = crash (TCP sockets on X)
      • From: Matt Slot <email@hidden>
  • Prev by Date: Re: UDP endpoints
  • Next by Date: Re: send on unconnected socket = crash (TCP sockets on X)
  • Previous by thread: Re: UDP endpoints
  • Next by thread: Re: send on unconnected socket = crash (TCP sockets on X)
  • Index(es):
    • Date
    • Thread