Article View: comp.unix.programmer
Article #3265connect/read/write vs sendto/recvfrom
From: Patrick Coghlan
Date: Thu, 07 Apr 1994 15:04
Date: Thu, 07 Apr 1994 15:04
23 lines
1808 bytes
1808 bytes
We are using sockets with UDP in our application.
The connect() system call binds our port number and sets up the
remote port number and IP address. Most of the time there is
no peer at the other end, but the connect() and first write()
do not return any errors.
What does seem to happen is that a packet arrives at the socket
after doing the write() and the subsequent read() that we perform
returns error #239 - connection refused. We only receive this
error when the remote end is located at a different IP address.
Is the following assumption about what is happening correct:
- there is no connection-related handshaking involved since
UDP is selected as the protocol but the packet is being
returned because it could not be delivered (port number
was not assigned)
If this is the case, I want to just ignore the "connection refused"
error. I don't remember getting this error when we were using
sendto()/recvfrom() but we hadn't tried sending packets to a
different IP address either.
Technical Details
Message-ID:
<1994Apr7.150412.12826@bcarh54a.bnr.ca>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!darwin.sura.net!howland.reston.ans.net!pipex!bnr.co.uk!corpgate!bnrgate!bcars267!bcarh54a!bcarh5f8!coghlanShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,ce20a78f46f0eba6,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 14b500,ce20a78f46f0eba6,start X-Google-Attributes: gid14b500,public X-Google-ArrivalTime: 1994-04-07 08:04:12 PST Newsgroups: comp.unix.programmer,bnr.unix Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!darwin.sura.net!howland.reston.ans.net!pipex!bnr.co.uk!corpgate!bnrgate!bcars267!bcarh54a!bcarh5f8!coghlan From: coghlan@bcarh5f8.bnr.ca (Patrick Coghlan) Subject: connect/read/write vs sendto/recvfrom Message-ID: <1994Apr7.150412.12826@bcarh54a.bnr.ca> Sender: coghlan@bcarh5f8 (Patrick Coghlan) Date: Thu, 7 Apr 1994 15:04:12 GMT Nntp-Posting-Host: bcarh5f8 Organization: Bell-Northern Research, Ottawa, Canada Lines: 23