QUESTION: How Do I determine the PID associated with a Socket

Is there a way to determine the PID associated with a socket ?

I have examined the /etc/services file and grepped thru the /etc/init.d
dir for the Port in use w/o success.

Thanks in  advance for any assistance in this matter.

10/20/2005 3:48:48 PM
comp.unix.solaris 25916 articles. 0 followers. Post Follow

3 Replies

Similar Articles

[PageSpeed] 14 wrote:
> Is there a way to determine the PID associated with a socket ?

"lsof" should help you has solaris binaries of lsof.


Rap it up for the common good
Let us enlist the neighbourhood
It's OK, I've overstood
This is a wordy rappinghood. OK, bye.

                   Tomtomclub, 1980.
10/20/2005 4:21:05 PM wrote:
> Is there a way to determine the PID associated with a socket ?

Or using native commands without using lsof is to use pfiles.

cd /proc
pfiles * > /tmp/pfiles.out

search through pfiles.out for the process that has the socket open you 
are interested in. i.e. there will be entries such as:

3771:   /export/home/archiver/bin/myprocess
   Current rlimit: 256 file descriptors
    0: S_IFCHR mode:0666 dev:85,0 ino:191320 uid:0 gid:3 rdev:13,2
    1: S_IFCHR mode:0666 dev:85,0 ino:191397 uid:0 gid:0 rdev:24,2
    2: S_IFREG mode:0644 dev:85,5 ino:17 uid:104 gid:1 size:139436
    3: S_IFDOOR mode:0444 dev:293,0 ino:58 uid:0 gid:0 size:0
       O_RDONLY|O_LARGEFILE FD_CLOEXEC  door to nscd[200]
    4: S_IFSOCK mode:0666 dev:287,0 ino:19574 uid:0 gid:0 size:0
         sockname: AF_INET  port: 9001
         peername: AF_INET  port: 9001

pid 3771 has port 9001 open locally.

10/20/2005 9:06:02 PM
Michael's pfiles suggestion is probably the best way of doing this.
We're thinking about better ways; it's tricky, since
a single open socket can be shared amongst many processes.
You can also use DTrace to do this on Solaris 10 if the problem is
repeatable, but it's not trivial.

- Bart

10/21/2005 6:09:43 AM
Similar artilces about - QUESTION: How Do I determine the PID associated with a Socket:

simple destructor question
Hi All, if I have a class that uses a STL list of pointers like: class SomeClass { private: list<OtherClass*> aList; --other stuff-- } If I just do aList.clear() in the destructor is that sufficient or do I have to do a delete on each pointer in the list? Thanks for your help Michael michael wrote: > Hi All, > > if I have a class that uses a STL list of pointers like: > > class SomeClass { > private: > list<OtherClass*> aList; > --other stuff-- > } > > If I just do aList.clear() in the destructor is that ...

X11 question
I downloaded X11 at Apple's website, but this is a rootless system and so when I run it I can't have, say, IceWM or Windowmaker manage the windows for me. Is there a version of X11 that comes in a package that would install as easily as Apple's version of X11, and one in which I could run whatever window manager I wanted? Thank you. -- GR Gaudreau <> <grgaud at sympatico dot ca> On 2003-10-20, GRGAUD <> wrote: > I downloaded X11 at Apple's website, but this is a rootless system and > so when I run it ...

selectOneMenu simple question...
Hi guys, i'm a question for you.I'm using for the first time a selectonemenu tag in my JSF application and i've this error javax.servlet.ServletException: javax.servlet.jsp.JspException: Value binding '#{user.teams}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /Login.jsp][Class: javax.faces.component.html.HtmlForm,Id: _id1][Class: javax.faces.component.html.HtmlPanelGrid,Id: _id2][Class: javax.faces.component.html.HtmlPanelGrid,Id: _id4][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: selectTeam][Class: jav...

Here is one solution data a ; input subject variableun $ 10-35; variableun=compress(variableun,';'); if INDEX(variableun,'ONGO') THEN VAR='A';ELSE VAR='B'; KEEP VAR; cards4; 1 City Bus leaving - ONGO; 2 Cneter city, california 3 City center colosed - ONGO 4 Center city working - ONGO; 5 Uptown Bronx, New York; 6 Mall center Closed ONGO ;;;; run; proc print; run; Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-...

This works fine print "*" x 10; print "\n"; But is there a way to print *'s then a newline in one line print "*" x 10"\n"; doesnt work. Tks begin 666 cvidal.vcf M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..CMC=FED86P-"D9..F-V:61A M; T*14U!24P[4%)%1CM)3E1%4DY%5#IC=FED86Q 871T+F-O;0T*4D56.C(P ;,#,P.# X5#$S,3@R,%H-"D5.1#I60T%21 T* ` end >>>>> "Chris" == Chris Vidal <> writes: Chris> print "*" x 10"\n"; doesnt work. print "*" x 10, "\n"; ...

Determine if Telnet is enabled
Hi Everyone, I am performing an review of a Passport 8600 and would like to know from the configuration output, how do I tell if telnet is enabled. I have the following lines configured sys access-policy policy 1 service ftp enable sys set ssh enable true This tells me ssh is enabled and that ftp is enabled via access policy. How do I know if telnet is enabled or is it on permanently? Thanks. Tom. ...

My question
Hello, Today many parallel applications that are disk bound and/or memory bound can not scale on multicore systems. The question is not how to add more and more cores to a multicore system, the problem is how to scalable and speed more the memory system and hardisk system to be able to scale many more applications that are disk or/and memory bound. Thank you, Amine Moulay Ramdane. ...

personal smtp server question
Hi, I would like to install my personal smtp server to protect my privacy. I suspect that my ISP has blocked this option. I have tried to telnet the smtp server of my office at port 25 and not success. Any other solution? Thanks ...

Question about pychecker and pylint
Hi, I wonder if pychecker projet is dead ? On pychecker home page (, last version date from February 3, 2006 and their mailist contain spam messages only. Other tools like pychecker is pylint at ( This is a great tools and it's still active. However, it has issue : its web site, it is very incomprehensible. Do you have other pylint web site ? Thanks for your information. Stephane ...

Newbie : Cross Tab Question
I wanted to create a cross tab like the result below.I wanted to do it via code. The important thing is that the totals end up at the end. Also, the percentage represent the share of the total for that line. Item 1 Percentag 1 Item 2 Percent 2 Total Items Sold Customer A 6 items sold 60% 4 Items sold 40% 10 Items Sold Customer B 25 items sold 50% 50 Items sold 50% 100 Items Sold How can I do the above via code. ...

Various Questions
How many of you are using Solaris Resource Manager in a production environment? For those of who in cross-platforms, how many use AIX Workload Manager? Is anyone using ADR? Is it in connection with SRM (ie. trigger a DR when some SRM limit is hit for a period of time)? How many of you are using the SEToolkit? What do you like about it? What additional functionality would you like to see? Same questions for other performance tools - what do you like about the tool? What is missing? You can post responses here or directly to me ( Thanks in advance, Joe Rich - TeamQ...

Questions, Questions, Questions -- Well, really only two
This newsgroup seemed distribution non-specific so here goes: 1. Many companies who want to use linux, want it for email and web service. These systems don't need xwindows, and, in fact, as I understand it, not installing it not only saves resources but reduces security risk. Is there anywhere freely available a how-to install various current distributions of linux using text only, and installing mail, web and domain name service that is fairly easy for the uninformed to follow? Especially helpful would be a debian install. 2. Does anyone know of an encyclopedia, preferrably text-b...

XML beginners question
Good day, I am new on this newsgroup. For a project I am asked to read a XML data file into memory structure (entity structure/values). My question: What do I need for this? Are packages for this, are there some links for tutorials/information about this? I am a beginner on this issue, so please give me a few key-words to search for. Regards, Mike > My question: What do I need for this? Are packages for this, are there > some links for tutorials/information about this? I am a beginner on this > issue, so please give me a few key-words to search for.

JCE question
Having played a lot with encryption and signing on the MS (shhhh!) .NET platform I decided to play around with the Java Cryptography E(nvironment?). In JCE I have gotten around to make some encrypt/decrypt playground utility using PBEWithMD5AndTripleDES, yet I wonder, is that the same as DESede which can also be given as the encryption algorithm? Basically I want to develop an encryption utility that I fully understand but this PBE thing I don't. Yes, I need to use a passphrase to do the encryption but why can't I do that with just selecting DESede as the algorithm (that is Trip...

how to determine whether variable is a scalar or an array?
I need the perl equivalent to a function like PHP's is_array() to check the type of a perl variable. Imagine this: Let's define an array which can be either @arr = (1, 2, 3); or @arr = ( [ 1, 2], [3, 4], [5, 6] ); ie, a list or an array of arrays (strictly speaking, a list of array references). Now I want to dump the array (whether it is a list or an array of arrays) with a code block like this: ----------------------------------------- for $element ( @arr) { if (UNKNOWN TEST FOR SCALARITY) { # one dimensional list print "next scalar: $element\n"; } el...

49g+ question
Peace to you all I want to ask you all, something about my hp 49g+: everytime i try to enter a simple calculate like: 2 * p (the pay sign, 3.14...) and then i press "Enter" i get: 2.*p ? each time i must use the "Eval" button to get a properly answer. i use the latest rom version in algebric mode. thanks, Dan. Hold right shift down and press and release ENTER then release the shift key, too That will change you into Approx. mode (instead of Exact) And in the header = changes to ~ in order to indicate your mode change Alternatively you can press [MODE] then |CA...

fmincon question #6
I'm working on an optimization problem, and I'm having trouble setting up the constraints properly. The function that I am minimizing takes two inputs. It calls a number of other functions, but in the end returns a scalar output. The two inputs to the function are constrained, and I know how to do that. However, there are variables inside the function that I am minimizing that I need to constrain. These internal variables are dependent upon the two inputs and so can't themselves be inputs to the function I am minimizing. How would I constrain these internal variables (if it i...

Some questions
1. I can't find any brief description of PL/I grammar. 2. Are some editors, that support PL/I? Or, at least, parse files? 3. Have some body experience with multithreading facility of VA PL/I? Any tricks? 4. I'd like to call some Fortran subroutines from VA PL/I program. What compiler/linker is preferable? 5. PL/I have a big story, but I can't find any sufficiently big collection of PL codes (especially numerical). On my look, for IBM and Multics it sould be a lot. May be somebody knows about such collection(-s)? MZN wrote: > 1. I can't find any brief description of P...

Epson 2200 refilling question
I'm getting mixed answers from ink suppliers on this--do the 2200 carts (T034..) contain sponges or not? Has anyone sawed one open to find out? One of the problems refillers have with recent Epson carts is that these newer sponges deteriorate or harden quickly, limiting the number of refills and also the amount of ink that can be re-introduced. The sponge problem does not exist for 3rd party cartidges intended for refilling. This could be seen as another attempt to thwart refilling (in addition to the chip). But I'd also heard that internal sponges and pigment-based inks w...

Optimization question
The way I decided to get rid of end-of-line characters in existing strings for my little word-wrap project was to Translate() both '0d'x and '0a'x to spaces and run the resulting string through Space(). (I planned on using Space() anyway, so it added little.) This lets me allow for instances where the string uses the *nix end-of-line. I have it written as follows: strng = Space(Translate(strng,' ','0d0a'x)) It got me thinking. I used to do this sort of thing as follows next, because I find it easier to read: strng = Translate(strng,' ','0d0a...

Sockets #2
Hi, I'm trying to familiarise myself with socket programming in PHP on a XP Home SP2 box with Apache 2.0.58 / PHP 5.1.4. I've ran a few basic scripts now which I accessed through a telnet session. The purpose of these scripts is to simply return the input I type. They all pretty much have the same routine as shown below: -- begin snippet -- do { // read client input $input = socket_read($spawn, 1024, PHP_NORMAL_READ) or die("Could not read input\n"); if (trim($input) != "") { echo "Received input: $input\n"; // if client requests sessi...

XmRendition, XmRendertable...have a question on this code?
Hello, I have been trying to make it so that I can color specific lines of text within my List scroll window under X-Designer and Motiff. I have found that I can use what is called a Rendertable that is loaded with defined Rendition elements. I have figured out how I can change the color of the text and even change the font within my program but for some reason I am not able to change indivdual lines to different font properties. Here is what I have: I have a "for" loop that reads in information from a settings file to fill in the list scroll window information. First we c...

Sar questions
Below is my sar output. How can we know that what caused the cpu to consume 100% CPU at all time? #sar 00:00:00 %usr %sys %wio %idle (-u) 01:00:00 25 75 0 0 02:00:00 25 75 0 0 03:00:00 24 76 0 0 04:00:00 24 76 0 0 05:00:00 24 76 0 0 06:00:00 24 76 0 0 .. .. (%idle = 0 all the time) #sar 1 5 23:30:19 %usr %sys %wio %idle (-u) 23:30:20 24 76 0 0 23:30:21 24 76 0 0 23:30:22 16 84 0 ...

Netstat question.
tcp 0 1 wonderland:33390 SYN_SENT tcp 0 0 wonderland:33375 neotokyo:ssh TIME_WAIT udp 0 0 localhost:32782 localhost:32782 ESTABLISHED I see these addresses when I type 'netstat'. Is there a way to force a connection to close? For instance, I don't know what the third line is--it's new to my system logs; how can I close it? Thanks, Naota -- naSota@tPampabay.rAr.cMom - > (remove capital letters: SPAM) Naota <see@the.signature> wrote: > tcp 0 ...

Getting the PID of a process ID
Hi, I'm using Ubuntu 11.04. How do I get the process ID of a process I just kicked off in a script? I have /usr/bin/Xvfb :15 -ac -screen 0 1024x768x16 & XVFB_PID=$! echo $XVFB_PID > /var/run/ su selenium -c 'java -jar /opt/selenium/selenium-server- standalone-2.0b3.jar -userExtensions /opt/selenium/user-extensions.js > /var/log/se_rc_server.log 2>&1 &' PID=$! echo $PID > /var/run/ However both the XVFB_PID and PID are the same value, and neither is the value of what was just kick...