f



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.

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

3 Replies
1020 Views

Similar Articles

[PageSpeed] 42

mark.m.lloyd@ae.ge.com wrote:
> Is there a way to determine the PID associated with a socket ?


"lsof" should help you

ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/

blastwave.org has solaris binaries of lsof.

Rob

-- 
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.
0
Rob
10/20/2005 4:21:05 PM
mark.m.lloyd@ae.ge.com 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
       O_RDONLY|O_LARGEFILE
    1: S_IFCHR mode:0666 dev:85,0 ino:191397 uid:0 gid:0 rdev:24,2
       O_RDWR|O_LARGEFILE
    2: S_IFREG mode:0644 dev:85,5 ino:17 uid:104 gid:1 size:139436
       O_WRONLY|O_LARGEFILE
    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
       O_RDWR
         sockname: AF_INET 10.1.1.1  port: 9001
         peername: AF_INET 10.1.1.2  port: 9001

pid 3771 has port 9001 open locally.

--
Michael
0
Michael
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

0
barts
10/21/2005 6:09:43 AM
Reply:

Similar Artilces:

Need help with a simple UNIX sockets server based on IO::Socket::UNIX
Hi. I've tried to create a simple client + server that communicate through a unix socket. As with all socket servers, it has a loop where it waits for connections: while ($client = $sock->accept()) { # handle client here } The problem is that $sock->accept() is returning undef on each alternate client connection with error "No child processes". I made this temporary workaround that does work but of course I must be screwing up somewhere else: while ($client = $sock->accept() || $client = $sock->accept()) { # handle client here } I hope someone can help or provide an example. I've included the client + server code below for those who are interrested in taking a peek. Thanks, Craig Manley ############ client ############ #!/usr/bin/perl -w use strict; use IO::Socket; my $sockname = 'mysocket'; my $client = IO::Socket::UNIX->new('Peer' => $sockname, 'Type' => SOCK_STREAM, 'Timeout' => 50) or die "$0: error connecting to '$sockname': $ [at] \n"; my $pid = fork(); unless(defined($pid)) { die("Fork this! I cannot forking fork!\n"); } if ($pid) { write_sock(); waitpid($pid, 0); } else { read_sock(); } sub write_sock { for (1..10) { print $client "testline number $_\n"; # print to socket } print $client "\n"; # empty line causes server to terminate connection p...

Unix socket with MTA-MSP question
I'm trying to setup a server's email so that when things are mailed to root (from cron for instance), a copy of the email is kept in /var/mail/root (local delivery) and is sent to several recipients on other machines. I know I can setup the recipients via the aliases file. I also need to make every effort to not have any tcp port open for email (not even for 127.0.0.1). I've read in the www.sendmail.org/m4/README.txt (sendmail configuration files) in the ANTI-SPAM CONFIGURATION CONTROL section about the entry "[UNIX:localhost]" in RELAY_DOMAIN_FILE() allowing relaying via a Unix socket (not tcp socket). Would this allow the MSP to submit email to the MTA which could deliver it to all the recipents? Has anyone done this? What would defeat this mechanism? I've read some articles about turning off sendmail for security reasons, or assigning email to some other port than 25 and using local or smart relays, but I haven't seen anything that indicates the Unix socket would work. My system is Redhat Linux ES 3. Sendmail is 8.12.11 ---Thanks for any info ---Mike Cannady "Mike Cannady" <mike.cannady@sccoast.net> writes: > I'm trying to setup a server's email so that when things are mailed to root > (from cron for instance), a copy of the email is kept in /var/mail/root > (local delivery) and is sent to several recipients on other machines. I > know I can setup the recipients via the aliases...

UNIX Server Monitoring (Solaris)
Supposedly there is a server monitoring product by Computer Associates. Has anyone had any experience with CA monitoring products and if they are any good? Thanks On Nov 22, 6:38 pm, Michelle <newsgrps_rem0ve_t...@mst.ca> wrote: > Supposedly there is a server monitoring product by Computer Associates. > > Has anyone had any experience with CA monitoring products and if they > are any good? > > Thanks I have 3 years experience with that sort of thing. I will gladly answer your questions. But try to be more specific. But generally speaking - CA does the drill. On No...

Questions about Gnat.sockets and raw socket
Hello, For a personal project, I want to create a packet analyzer. Can I use Gnat.socket, for raw socket programming ? it is not clear for me, and unfortunately I didn't found any answers in the ada groups. I will use it under Windows. Thank you Best Loic On Thu, 23 Apr 2015 02:21:00 -0700 (PDT), lo�c maury wrote: > For a personal project, I want to create a packet analyzer. > Can I use Gnat.socket, for raw socket programming ? it is not clear > for me, and unfortunately I didn't found any answers in the ada groups. > > I will use it under Windows. The short answer is no, it would not go. Windows does not support raw sockets (naturally GNAT.Sockets does not do either). Under Windows you will need a so-called NDIS driver to handle packets away of the network stack, and Ada bindings to. I can recommend an inexpensive NDIS driver we are successfully using under Windows: http://www.rawether.net We also have Windows bindings to it, but they are proprietary. P.S. Under Linux you would use raw sockets. GNAT.Sockets does not support them, but it is relatively simple to adapt. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de Le jeudi 23 avril 2015 14:19:04 UTC+2, Dmitry A. Kazakov a =C3=A9crit=C2=A0= : > On Thu, 23 Apr 2015 02:21:00 -0700 (PDT), lo=C4=8Fc maury wrote: >=20 > > For a personal project, I want to create a packet analyzer. > > Can I use Gnat.socket, ...

Solaris 8 and Solaris 10 storage questions
Hey there, I recently mirrored my internal HDD and everything went fine other than when I issued installboot /usr/platform/'uname -i'/lib/fs/ufs/bootblk /dev/rdsk/ c0t1d0s0 (command) the system responds as :file not found. Any ideas on this?? Other question is that how do I find out which LUN is available to system. I mean once the storage person assigns a server a LUN how do I make use of that LUN, which command should I use to use that LUN. My server is using Solstice DiskSuite 4.2.1. Once the LUN is available for the system am I still limited to 7 partitions on that LUN? Do I hav...

Question about Streams and UDP sockets using GNAT.Sockets
Hi. I'm using GNAT GPL 2006 (20060522-34) on Windows XP. I'm trying to broadcast an UDP packet, with the following test code: ---------------------------------------------------------------------- with GNAT.Sockets; use GNAT.Sockets; procedure Test is Local_Port : constant Port_Type := 20769; Remote_Port : constant Port_Type := 20770; Address : Sock_Addr_Type; Socket : Socket_Type; Channel : Stream_Access; Local_Host : String := "127.0.0.1"; begin Initialize; Create_Socket (Socket, Family_Inet, Socket_Datagram); Set_Socket_Option (Socket, Socket_Level, (Broadcast, True)); Address.Addr := Inet_Addr (Local_Host); Address.Port := Local_Port; Bind_Socket (Socket, Address); Address.Addr := Broadcast_Inet_Addr; Address.Port := Remote_Port; Channel := Stream (Socket, Address); String'Write (Channel, "TEST"); -- sends "T", "E", "S", "T". Free (Channel); Close_Socket (Socket); Finalize; end Test; ---------------------------------------------------------------------- The trouble I'm having is not about sockets, but the streams vs. sockets interaction. The above code does not send one UDP packet, but four, one for each byte of the test message. What I'm doing wrong? Thanks, Juanma On 18 Jul 2006 02:41:06 -0700, lekktu@gmail.com wrote: > I'm using GNAT GPL 2006 (20060522-34) on Windows XP. > > I'...

porting solaris/SPARC app to Solaris/x86 questions
I am porting some apps which have always run on SPARC to x86. The biggest concern is that they read and write binary data. I would line the x86 and SPARC versions to work on the same data set. I read http://developers.sun.com/solaris/articles/support_for_x86.html, where it states that the Solaris OS handles the endianness. But then it mentions raw binary storage b/n SPARC/x86 is not dealt with... The apps read and write data as structs: <example> typedef struct{ int x; int y; float z; float a; int b; u_longlong_t address; }DATA_ADDRESS_STRUCT; DATA_...

Unix domain socket (AF_UNIX) support for Java sockets
Hi all, Java doesn't support AF_UNIX (Unix domain sockets) in their socket implementation as far as I can tell. Sun has an RFE (4145756) logged against Java that notes: "The existing java socket model is far too specific to IP and there is no straight forward way to use a UNIX domain socket (or a Windows named pipe) in the existing system. As far as I can tell we need a greater degree of abstraction for the concept of a socket address so that a socket can be created for IP or another domain either explicitly or simply by the type of the address, e.g. [ ... ] A socket implementation factory could be choosen based on the type of address." Does anyone know of / have code that supports AF_UNIX for Java sockets? Chris ...

Sockets question
Hi, One of the exercises in front of me is: "Write a server in perl that will send the client a sleepy string of "ZZZZZZZZZ" whenever it connects using port 54321 from the same host using a socket in the UNIX domain." Can someone possibly re-phrase the question? I have no idea about sockets - just found a chapter on it in Prog. Perl but have not read it yet :(. Any links out there I can get ideas/learn from? Thanks in advance. John wrote: > > One of the exercises in front of me is: > "Write a server in perl that will send the client a sleepy string of &...

Socket question
When creating a socket with new Socket(host, port) the connection is made as part of the object creation process. If the remote host sends an initial login text, where does this go? I cannot seem to retrieve this text, as I create BufferedReader from the InputStream later? "GaryM" <garymcm@yahoo.com> wrote in message news:Xns9425708BF6E20R3344324357788499939@216.168.3.44... > When creating a socket with new Socket(host, port) the connection is > made as part of the object creation process. If the remote host sends > an initial login text, where does this go? I can...

Socket question
Hi, If two clients contact a server, a fileevent is started on each one, then is it possible that both sockets become readable at the same time. If that happens then what is the sequence of functions based on the events being called. e.g. socket1 fileevent calls --> proc1 socket2 fileevent calls --> proc2 if both sockets become readable at the same time, does tcl fork and execute both in parallel, or it executes one after the other, like proc1 after proc2. Is tcl capable of parallel execution in this context. Or tcl does not even see them at the same time. Pandey shardendu@tenesix.com (a2zasics) writes: > If two clients contact a server, a fileevent is started on each one, > then is it possible that both sockets become readable at the same > time. If that happens then what is the sequence of functions based > on the events being called. e.g. > socket1 fileevent calls --> proc1 > socket2 fileevent calls --> proc2 I'm not sure it's a given what order they will be called in - I wouldn't count on it. > if both sockets become readable at the same time, does tcl fork and > execute both in parallel, or it executes one after the other, like > proc1 after proc2. Is tcl capable of parallel execution in this > context. Or tcl does not even see them at the same time. Tcl does not fork or use threads for normal socket handling (although threads are available as an add-on). It uses a select-based event loop, so th...

Unix Question
How can I change file permissions so that it becomes a direcoty ? Gandhi <amolg1977@indiatimes.com> wrote: > How can I change file permissions so that it becomes a direcoty ? You can't -- Peter H�kanson IPSec Sverige ( At Gothenburg Riverside ) Sorry about my e-mail address, but i'm trying to keep spam out, remove "icke-reklam" if you feel for mailing me. Thanx. amolg1977@indiatimes.com (Gandhi) wrote: > How can I change file permissions so that it becomes a direcoty ? A directory is already a file, altho...

Sockets Question
If I succesfully create a Socket as follows: Socket sock = new Socket("192.168.1.55", 1000); Then, go to send data, and listen in on it as follows: BufferedWriter os = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())); BufferedReader is = new BufferedReader(new InputStreamReader(sock.getInputStream())); try{ os.write("D0"); os.flush(); returnedString =is.readLine(); System.out.println(returnedString); }...

sockets question
1. When reading from a socket, how does socket timeout work? Will an fgets wait for timeout length per attempt, or timeout is the time allowed for repeated fgets attempts, such as in a loop? 2. Does timeout have an effect if a socket is set to nonblocking, or does it apply to blocking sockets only? mydejamail@yahoo.co.uk wrote: > 1. When reading from a socket, how does socket timeout work? > Will an fgets wait for timeout length per attempt, or timeout is the > time allowed for repeated fgets attempts, such as in a loop? > Per attempt > 2. Does timeout have an effect if a socket is set to nonblocking, or > does it apply to blocking sockets only? It only applies to blocking sockets JW ...

sockets question
Hi all, we have a project where we'd like to interface with a C++ program, possibly residing on another machine. Sockets seem to be the best method to do this. The project requires 10's of kilobytes of information to be passed in both directions. Mostly this is numerical data (int / floating point) with some strings, and some larger arrays of numerical data. Speed is not critical. Security is of little importance (we won't need encryption). Ease of programming (quick ramp up) is very important. Would you have any recommendations as to: 1) a good sockets library. Preferabl...

Questions, Questions...
Hi! I took the routine from Gastronor.mdb: In the frmOrderDetails -> ITemID_AfterUpdate: Dim strFilter as String strFilter = "ItemID = " & Me!ItemID but it didn't work on win 2000 with access 2000. However, after playing around for a while, I found: Me!UnitPrice = ItemID.Column(2) to work just fine, even after updating prices in the tblItems. Anybody knows why? The routine in win 98/win nt in the footer of frmOrderDetails: =Sum((Price*Amount*(1-[Discount])/100)*100)) didn't either work. After testing and trying I finally discovered that =Sum(Price*Amount*Discount) does the job on win 2000. ???? What is happening? Anybody know if there is a major difference in this thing from win98/win nt to win 2000? (I should maybe say that I'm working only with DAO 3.6) Questions: 1.I have my own four buttons on frmOrders (btnGoToFirst,btnGoToPRevious,btnGoToNext,btnGoToLast). How can I disable them: when user click GoToLast and comes to last order and I wish that btnGoToNext and btnGoToLast should be disabled, and similarly with the first record? Anybody know an article on this? 2.I have two invisible fields on the form. I=chkWritten and II=chkCreditMemo In the cmdWriteCreditMemo I want to check whether I and/or II is checked. Because the user should not be able to print a CreditMemo if either he forgot to print an invoice first, or if he already sendt both invoice and creditmemo to printer. I have been trying: if (Me.chkPrinted.Value=False) AND ...

Socket Question
I am in the process of teaching myself socket programming. I am "playing around" with some simple echo server-client programs for m the book TCP/IP Sockets in C. The Server program is: #include "TCPEchoServer.h" /* TCP echo server includes */ #include <pthread.h> /* for POSIX threads */ void *ThreadMain(void *arg); /* Main program of a thread */ /* Structure of arguments to pass to client thread */ struct ThreadArgs { int clntSock; /* Socket descriptor for client */ }; int main(int argc, char *argv[]) { int servSock...

unix question
I have 2 IP's on one nic ftp is enabled on the server can I restrict ftp to one IP so that port 21 will not be open on the 2nd IP this way I can have another service listening on port 21 of the second IP Many thanks in advance S dsdsd wrote: > I have 2 IP's on one nic ftp is enabled on the server can I restrict > ftp to one IP so that port 21 will not be open on the 2nd IP this way I > can have another service listening on port 21 of the second IP Depending on the ftpd, you have different options. Pureftpd (http://www.pureftpd.org/) can do all of this. If you want ...

associativity question
Associativity in C takes two forms: left to right and right to left. I think the K&R book lacks something... For example, *p++, since the associativity is from right to left, do this expression means *(p++)? I think I am wrong. (so, associativity is not for operand?) But for *++p, right to left associativity means *(++p) is correct. So by definition of associativity, I guess it only applys on grouped operators but not on operand. Right? A more complicated example will be char* const *(*next++)() fdmfdmfdm@gmail.com said: > Associativity in C takes two forms: left to right and righ...

Questions over questions
Hello people, I have a problem with my ISP! He kills my php script, if they were executed over 30 seconds. Can I use some trick to fake a little bit? That I can execute the script longer!? Greeting! Sven Dzepina wrote: > Hello people, > > I have a problem with my ISP! He kills my php script, if they were executed > over 30 seconds. > Can I use some trick to fake a little bit? That I can execute the script > longer!? > > Greeting! > > If your ISP doesn't run your script in safe mode, which it most likely does, then you can set_time_limit(0); for unlimited execution time. Otherwise there is probably no way to let it run longer. "John Downey" <blah@doesntexist.com> wrote in message news:8pdib.121103$xx4.20419112@twister.neo.rr.com... > Sven Dzepina wrote: > > > Hello people, > > > > I have a problem with my ISP! He kills my php script, if they were executed > > over 30 seconds. > > Can I use some trick to fake a little bit? That I can execute the script > > longer!? > > > > Greeting! > > > > > If your ISP doesn't run your script in safe mode, which it most likely > does, then you can set_time_limit(0); for unlimited execution time. > Otherwise there is probably no way to let it run longer. > I heard a rumour that the sleep() function resets the script execution time each time it's called. So if you use it in conjunction with a lo...

Question on Unix ?
Hi to All, Can we do device driver programming in Unix and how it is diff. from Linux device driver programming? Thanks in Advance. Pravin On 4 Jan 2005 20:49:17 -0800, pra_m_shetty@rediffmail.com (Pravin Shetty) wrote in comp.lang.c: > Hi to All, > > Can we do device driver programming in Unix and how it is diff. from > Linux device driver programming? > > Thanks in Advance. > > Pravin Your question has nothing at all to do with the C language. It is not possible to write device drivers in standard C, so it is off-topic...

Not a Solaris Question- A Network Question- But I figure U guys are the smartest :)
Hello All, Got a question about ARP protocol. ( Its not for any Homework or anything like that...just my curiosity and I dont have envinroment to test it in right now) In a switched environment with where 2 nodes A and B want to communicate ( eg an ftp session). Node A wants the MAC of Node B ( the server in this case). It will send a broadcast ARP request. If the Switch already has the answer in its arp table, what will it do? 1) just answer the request sent out by A with B's MAC address 2) forward the arp request just to port for Node B 3) or will it broadcast the ...

sockets question
hi; i have the following piece of code: ============= s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.bind(("",port)) s.sendto(data,(MY_GW,port)) data = s.recvfrom(1024) ============ data contains some instructions which i am sending to MY_GW. If the reply arrives from the MY_GW quickly then things fine, otherwise the program is going to freeze waiting for the reply. I want to do the following: 1- Be able to impose a timeout after which i want to stop executing the s.recvfrom statement. rgds; m.smadi On Sat, 26 Feb 2005 00:35:57 -0500, Mohammed Smadi wrote: >...

Socket question..
I've have been using the following test for a socket connection breaking in a tcl client if {[eof $sock] || [catch { gets $sock line}]} { .. .. .. I've tested this by killing the server. The expression is evaluated true, a procedure is called and the client goes into a wait mode and waits for the socket to be come available again. Last night the host on which the server runs croaked, but this time the above expression didn't evaluate to true, or it was never evaluated in the first place. I have a statement: fileevent $s readable [list tcp_client read $s] THe test above is the first thing I do in tcp_client. What do I need to do to more effectively trap and detect this condition? Thanks in advance, Stuart Try if {[eof $sock] || [gets $sock line] < 0} { bla bla bla... } Dave In article <1116999984.943921.140330@g49g2000cwa.googlegroups.com>, "Stuart" <bigdakine@aol.com> wrote: In a TCP connection when neither host has anything to send and when there is no outstanding unacknowledged data then no traffic flows between the hosts. If one host goes down then, or a cable is disconnected or anything else happens to stop traffic from one to the other, a listening host won't be able to tell that the other end is unable to send to it. The best solution is to ensure that there is regularly traffic between the hosts, like a heartbeat or no op, and that each side has a timeout that triggers if it doesn't receive the heartbeat...

Web resources about - QUESTION: How Do I determine the PID associated with a Socket - comp.unix.solaris

Chinese Herbalist's Family of 3 Killed, Man Arrested
A popular practitioner of Chinese herbal medicine was found shot to death and wrapped in plastic along with his wife and 5-year-old daughter ...

Attacking Cruz's wife could hurt Trump with female voters
OSHKOSH, Wis. (AP) — Donald Trump's latest rude comments about Ted Cruz's wife are raising new alarms among Republicans about the party front-runner's ...

'Batman v Superman': What actually happened in Batman's dream, and what it means for 'Justice League' ...
Caution: Batman v Superman: Dawn of Justice spoilers ahead. There's a moment in Batman v Superman when — with no warning — we see the Caped ...

Slowing mobile videos a savvy tactic for Netflix
Netflix Inc. has long framed itself as the good guy in the fight against Internet service providers — Chief Executive Reed Hastings has described ...

TIPPING OFF: 4 games, 4 upsets in women's Sweet 16
BRIDGEPORT, Conn. (AP) — What a wild night in the women's NCAA Tournament. Four games, four upsets.

Apple Music just got a new feature on Android that’s not coming to iOS any time soon
Not long ago, Apple brought its Apple Music app to Android. Having to compete with established powerhouses like Spotify and Pandora, Apple knew ...

Sanders eyes Western comeback, chips away – slightly – at Clinton lead
Fox News Sanders eyes Western comeback, chips away – slightly – at Clinton lead Fox News Bernie Sanders is looking ever-westward for a shot ...

Is Anything Open Easter Sunday? Restaurants, Walmart, Banks Open Or Closed March 27?
Planning to go out to eat on Easter Sunday and spend some time at the mall shopping the holiday weekend sales? Here’s the scoop on what’s open ...

Google warn Gmail users of ‘government backed attacks’ after supporting Apple's privacy case
Google will now provide full-page warning with instructions about how these users can stay safe. The company said it will also be increasing ...

Don’t miss Conan’s touching tribute to the late Garry Shandling
The comedy world lost a major figure this week when Garry Shandling, the comedic brain behind the groundbreaking series It's Garry Shandling's ...

Resources last updated: 3/26/2016 8:20:55 AM