Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S269949AbUJNCOl (ORCPT ); Wed, 13 Oct 2004 22:14:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S269948AbUJNCOl (ORCPT ); Wed, 13 Oct 2004 22:14:41 -0400 Received: from arnor.apana.org.au ([203.14.152.115]:59400 "EHLO arnor.apana.org.au") by vger.kernel.org with ESMTP id S269950AbUJNCNB (ORCPT ); Wed, 13 Oct 2004 22:13:01 -0400 From: Herbert Xu To: stsp@aknet.ru (Stas Sergeev) Subject: Re: [patch] allow write() on SOCK_PACKET sockets Cc: herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, linux-net@vger.kernel.org Organization: Core In-Reply-To: <416B5085.6070907@aknet.ru> X-Newsgroups: apana.lists.os.linux.kernel,apana.lists.os.linux.net User-Agent: tin/1.7.4-20040225 ("Benbecula") (UNIX) (Linux/2.4.27-hx-1-686-smp (i686)) Message-Id: Date: Thu, 14 Oct 2004 12:12:56 +1000 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1479 Lines: 40 Stas Sergeev 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~} 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/