home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / programm / 5853 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.6 KB  |  61 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!walter!porthos!delphinus!chw
  3. From: chw@bellcore.com (Charlie Woloszynski)
  4. Subject: DGram sockets (UDP) and select on SunOS 4.1
  5. Reply-To: chw@bellcore.com
  6. Organization: Bellcore
  7. Date: Thu, 7 Jan 93 18:24:10 GMT
  8. Message-ID: <1993Jan7.182410.21332@porthos.cc.bellcore.com>
  9. Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
  10. Lines: 49
  11.  
  12. From chw Thu Jan  7 13:15:44 1993
  13. To: jroberts@east.sun.com
  14. Subject: Socket question
  15.  
  16.  
  17. I am trying to use a socket (dgram, udp) between two processes and
  18. I'm having some difficulty with select().  Select returns immediately,
  19. telling me that the socket is ready for reading.  But, when I read
  20. it, the recv() blocks until the second process actually sends some data.
  21. Is this "normal" for datagram sockets and select?
  22.  
  23. Here is some more of the details:   I have two processes.  Each creates 
  24. a socket () (dgram, udp), bind()s it to a unique port, and connect()s to
  25. the remote address (host, port).  Since these are dgram sockets, this
  26. connect only set the remote address to use and receive from.  No real
  27. connection is established.  Anyway, I assume that this lets the
  28. kernel filter incoming datagrams to the appropriate socket this way.
  29. No errors are indicated by the
  30. return value, but the errno goes from 0 to EACCES (permission denied).
  31. The man page indicates this error is only for UNIX domain addresses,
  32. but I have used PF_INET exclusively for addressing.  The sockets I am
  33. using are not in /etc/services or any other system file I can think
  34. to look into.  Should they be (for dgram)?  If I
  35. add them, is there any processes that need to be restarted to recognize this
  36. change?
  37.  
  38. Now the first select call I do immediately returns (before the second
  39. process send to it).  So, my code does a recv() which now blocks until
  40. the second process sends something.  This characteristic repeats itself
  41. endlessly (well, as long as my patience lasted, about three minutes
  42. while I stewed and thought of other tests!!)  
  43.  
  44. I also tried putting the socket into non-blocking mode, in which case
  45. the recv() would return immediately (with errno=EWOULDBLOCK) and 
  46. then select would immediately indicate the socket was ready for input.
  47.  
  48. Any help would be greatly appreciated.
  49.  
  50. Charlie Woloszynski
  51. -----------------------------------------------------------------------------
  52. Charlie Woloszynski               MTS - ATM Technology and Applications
  53. Bellcore                 +01 201 829 5228 (voice)    
  54. Room MRE 2J-294                +01 201 829 5887 (fax)
  55. 445 South Street Box 1910        chw@bellcore.com (SMTP) 
  56. Morristown, NJ 07960-1910  USA        
  57. -----------------------------------------------------------------------------
  58.  
  59.  
  60.  
  61.