Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!ncar!jsloan@ncar.ucar.edu From: jsloan@ncar.ucar.edu (John Sloan,8292,X1243,ML44E) Newsgroups: comp.unix.wizards Subject: Re: sockets Message-ID: <7566@ncar.ucar.edu> Date: 6 Jun 90 19:01:35 GMT References: <4529@castle.ed.ac.uk> Sender: news@ncar.ucar.edu Lines: 27 From article <4529@castle.ed.ac.uk>, by elev26@castle.ed.ac.uk (Gerard A. Allan): > In article <4421@infmx.UUCP> kevinf@infmx.UUCP (Kevin Franden) writes: : >>Doesn't there exist a function to determin a preexisiting (I've >>heard some call this a "wellknown") service's socket number? : > sounds like you want, > struct servent *getservbyname(name, proto) > char *name, *proto; This is probably what he _needs_, although I'll probably be the Nth among M to point out that it's not what he asked for. getservbyname() returns the _port_ number for a "well known" service (i.e. defined in /etc/services, or if you have Yellow Pages, in the YP services file). A service's "socket" has no meaning outside the context of a particular process since a socket is merely a file descriptor (integer) that is specific to a paticular process. You must create your own socket (via socket()). Once you have the host address (e.g. via gethostbyname()) and port number (e.g. via getservbyname()) you can bind or connect your socket to that address and port. -- John Sloan +1 303 497 1243 ...!ncar!jsloan NCAR/SCD, POB 3000 AMA#515306, DoD#0011 jsloan@ncar.ucar.edu Boulder CO 80307 1990 BMW K75S Pilot jsloan%ncar@ncario.BITNET Logical Disclaimer: belong(opinions,jsloan). belong(opinions,_):-!,fail.