From owner-freebsd-questions Tue Oct 15 10:30:19 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 766DF37B401 for ; Tue, 15 Oct 2002 10:30:18 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC59543EA9 for ; Tue, 15 Oct 2002 10:30:17 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.6/8.12.5) id g9FHUHaS072275; Tue, 15 Oct 2002 12:30:17 -0500 (CDT) (envelope-from dan) Date: Tue, 15 Oct 2002 12:30:17 -0500 From: Dan Nelson To: alireza mahini Cc: questions@FreeBSD.ORG Subject: Re: How can i use the socket that created by a child in parent? Message-ID: <20021015173016.GB16975@dan.emsphone.com> References: <20021015171750.59644.qmail@web40702.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021015171750.59644.qmail@web40702.mail.yahoo.com> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Oct 15), alireza mahini said: > I create a stream socket in a child process and i want > to use it outside of child. > main(){ > int sd; > int fd[2]; > char buf[20]; > pipe(fd)); > if(!fork()){ > sd=socket(); > ... > ... > write(fd[1]....);//write sd to the pipe > } > read(fd[0],...)//read sd from pipe > send(sd,....);//error is occured in this line at > executing the program > ... > } > I understand that the descriptors don't send via pipe > to the outside of childs so guide me please. You'll need to use the sendmsg() and recvmsg() functions to pass the descriptor. See the unix(4), and recvmsg(2) manpages for more info. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message