title: iPhone Native system routines(datagram-socket-type)
body: <blockquote>
    <p>Sockets are full-duplex communication
    channels between processes either
    local to the same host machine or
    where one process is on a remote host.
    Unlike pipes, in which data goes in
    one direction only, sockets allow
    processes both to send and receive
    data. NSFileHandle facilitates
    communication over stream-type sockets
    by providing mechanisms run in
    background threads that accept socket
    connections and read from sockets.</p>
    
    <p>NSFileHandle currently handles only
    communication through stream-type
    sockets. If you want to use datagrams
    or other types of sockets, <strong>you must
    create and manage the connection using
    native system routines.</strong></p>
    
    <p>The process on one end of the
    communication channel (the server)
    starts by creating and preparing a
    socket using system routines. These
    routines vary slightly between BSD and
    non-BSD systems, but consist of the
    same sequence of steps:</p>
  </blockquote>
  
  <ol>
  <li><p>Create a stream-type socket of a
  certain protocol.</p></li>
  <li><p>Bind a name to the socket.</p></li>
  <li><p>Adding itself as an observer of
      NSFileHandleConnectionAcceptedNotification.</p></li>
  <li><p>Sending acceptConnectionInBackgroundAndNotify
      to this file handle object.</p>
  
  <p>This method accepts the connection in the
  background, creates a new NSFileHandle
  object from the new socket descriptor,
  and posts an NSFileHandleConnectionAcceptedNotification.</p></li>
  </ol>
  
  <p>Now I saw Michael answer .
  <a href="https://stackoverflow.com/questions/4004352/whats-the-difference-between-a-stream-type-socket-and-a-datagram-socket-type">About the differences between “stream-type” socket and a “datagram” socket type</a></p>
  
  <p>Do you have iPhone implementation example for native system routines(datagram-socket-type)?</p>