lkml.org 
[lkml]   [2004]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [patch] allow write() on SOCK_PACKET sockets
Date
Stas Sergeev <stsp@aknet.ru> wrote:
>
> I claim that SOCK_RAW allows write() after bind()
> because a few days ago I changed dosemu code
> to use SOCK_RAW instead of SOCK_PACKET and write()

Well I just checked net/ipv4/raw.c and it's pretty clear that it does

err = -EDESTADDRREQ;
if (sk->sk_state != TCP_ESTABLISHED)
goto out;

So you need to connect before you can write. I'm intrigued that
you can write before connecting on a raw socket. Could you please
write up a minimal program that I can play with?

> SOCK_PACKET. And btw, I can use read() quite
> happily even with SOCK_PACKET, so why not
> write()...

Well read() is different. It returns all packets received on
the socket, regardless of where they came from. So for a
connectionless socket it makes perfect sense to read() before
you've called connect().

OTOH, write() and send() needs to know where the message is going
to. That's exactly what connect() provides. So it makes no sense
to write()/send() before you've called connect().

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:07    [W:0.062 / U:2.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site