*BSD News Article 81686


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.netspace.net.au!news.mel.connect.com.au!munnari.OZ.AU!spool.mu.edu!newspump.sol.net!howland.erols.net!www.nntp.primenet.com!nntp.primenet.com!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail
From: brian@anorak.coverform.lan (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: How to open a socket under FreeBSD?
Date: 27 Oct 1996 22:49:37 -0000
Organization: Coverform Ltd.
Lines: 31
Sender: brian@awfulhak.demon.co.uk
Message-ID: <550ou1$2u0@anorak.coverform.lan>
References: <GORSKI.96Oct26172702@axiom.www.xxx>
Reply-To: brian@awfulhak.demon.co.uk
NNTP-Posting-Host: anorak.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.8

In article <GORSKI.96Oct26172702@axiom.www.xxx>,
	gorski@cips01.physik.uni-bonn.de writes:
: 
: 
: I want to open a socket under FreeBSD, but all the examples I've found for BSD
: use the 'struct sockaddr_in'. FreeBSD needs 'struct sockaddr'! I'm not familiar
: with sockets. How can I open a socket under FreeBSD?
: I've seen something like  connect(sock, (struct sockaddr *) &name, sizeof(name))
: in some source codes. Is that the way? This seems to be wrong for me.
: 
: Thanks for help (links to resources,dox,books,etc. are welcome).
[.....]

Sockets under FreeBSD are just like sockets under any other flavour
of unix (in my experience anyway) - so any book that covers unix sockets
will cover it.  I learnt by reading examples like the one you mentioned,
and reading the man pages on each of the calls.

The idea is that you create a socket, then either connect it to another
existing socket (via connect) or wait for a connection to occur
(via bind).  You can have different kind of sockets - normally either
a "unix domain" socket or an "internet" socket - depending on how
you create your socket.

Read the man pages and practice :)

-- 
Brian <brian@awfulhak.demon.co.uk>
      <http://www.awfulhak.demon.co.uk/>
Don't _EVER_ lose your sense of humour....
.