Checking who is listening on a Unix Domain Socket


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Checking who is listening on a Unix Domain Socket
# 1  
Old 06-18-2008
Checking who is listening on a Unix Domain Socket

Hi all,

I'm writing a kernel module and part of it involves controlling IPCs between processes. My problem is when a process tries to connect to a Unix domain socket, the only identifying information of the socket it supplies (that I can see, anyway) is the special pathname of the socket. From the pathname, I need to find out what process is binded/listening on it. Is there an easy way to do this? I would imagine that some data structures and functions in the kernel already would help with this but I just can't find anything helpful. Anyone know how to do this?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is my Socket Free or Listening

Hi, bash-3.2$ uname -a Linux mymac 2.6.18-409.el5 #1 SMP Fri Feb 12 06:37:28 EST 2016 x86_64 x86_64 x86_64 GNU/Linux bash-3.2$ telnet 10.12.228.40 13900 Trying 10.12.228.40... telnet: connect to address 10.12.228.40: Connection refused bash-3.2$ telnet 10.12.228.40 23900 Trying... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Programming

Unix Socket

Hai every one ,,, I am runinng one tcp socket in non-blocking mode. In the connect state(operation in progress) if the server is not running ,client socket select will give success. FD_ISSET(socketfd,&wfd) will give me succes always and am getting wfd value as 16. I tried with blocking... (6 Replies)
Discussion started by: andrew.paul
6 Replies

3. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

4. Windows & DOS: Issues & Discussions

How to: Linux BOX in Windows Domain (w/out joining the domain)

Dear Expert, i have linux box that is running in the windows domain, BUT did not being a member of the domain. as I am not the System Administrator so I have no control on the server in the network, such as modify dns entry , add the linux box in AD and domain record and so on that relevant. ... (2 Replies)
Discussion started by: regmaster
2 Replies

5. UNIX for Advanced & Expert Users

Unix: socket & Co

Hello, I need help to replace the ................. of client.c that request the server implemented by server.c ------------------ Listing 1 - server.c /* Inclusion des différentes librairies nécessaires */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> ... (0 Replies)
Discussion started by: bounkolh
0 Replies

6. UNIX for Advanced & Expert Users

UNIX domain sockets vs FIFOs

Is there a performance advantage of one of these over the other? Obviously, it makes no sense to use normal TCP sockets or UDP sockets w/ the overhead they carry. But what about UNIX domain sockets vs FIFOs? I'd think they'd be very similar, in terms of performance and in terms of how they're... (2 Replies)
Discussion started by: mgessner
2 Replies

7. UNIX for Dummies Questions & Answers

Joining UNIX to a Windows2003 Domain

Hey everyone, We have a Windows2003 Domain here at my workplace. I'm getting ready to switch over our bottom floor to the new domain. Will they still be able to see our UNIX machine that is setup now (on our workgroup) or will I need to join the UNIX machine to the domain. If that is the case... (4 Replies)
Discussion started by: Duki
4 Replies

8. UNIX for Dummies Questions & Answers

Adding a Unix machine to the domain

Hiya, what is the exact command to add a Unix machine to the existing domain? Is this command different for Linux/HP-Ux? thanks (3 Replies)
Discussion started by: Wize
3 Replies

9. UNIX for Dummies Questions & Answers

UNIX in MS Win2003 Domain

Hi, Can I make a UNIX or LINUX machine a member of MS Active Directory 2003? How? Regards Leo (4 Replies)
Discussion started by: Teamplay
4 Replies

10. IP Networking

Unix Domain

hello, how can we create a domain in unix operating systems. By domain i mean which is used to maintain remote user logins and etc. cheers (1 Reply)
Discussion started by: vibhory2j
1 Replies
Login or Register to Ask a Question
FBB::LocalClientSocket(3bobcat) 			     Unix Domain client Socket				   FBB::LocalClientSocket(3bobcat)

NAME
FBB::LocalClientSocket - Client Socket connecting to a Server in the Unix Domain SYNOPSIS
#include <bobcat/localclientsocket> Linking option: -lbobcat DESCRIPTION
An FBB::LocalClientSocket may be constructed to connect to a server process in the Unix Domain. The socket made available by the FBB:Local- ClientSocket may be used to initialize a std::istream and/or std::ostream. The std::istream is used to read information from the server process to which the FBB::LocalClientSocket connects, The std::ostream is used to send information to the server process to which the FBB::LocalClientSocket connects. Since a socket may be considered a file descriptor the avaiable FBB::IFdStream, FBB::IFdStreamBuf, FBB::OFdStream, and FBB::OFdStreamBuf classes may be used profitably here. Note that having available a socket does not mean that this defines the communication protocol. It is (still) the responsibility of the programmer to comply with an existing protocol or to implement a tailor-made protocol. The latter situation implies that the sequence of input- and output operations is defined by the programmer. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
FBB::LocalSocketBase CONSTRUCTOR
o LocalClientSocket(): This constructor merely creates a FBB::LocalClientSocket object. Before it can be used, its open() member must be called. o LocalClientSocket(std::string const &name): This constructor initializes an FBB::LocalClientSocket object, using the named Unix Domain socket to connect to the server using the named Unix Domain socket. An FBB::Errno is thrown if the socket could not be constructed. The construction of the socket does not mean that a connection has actually been established. In order to connect to the server, the member connect() (see below) should be used. The copy constructor is not available. MEMBER FUNCTION
o int connect(): This member returns a socket that can be used to communicate with the server process. An FBB::Errno exception is thrown if the con- nection could not be established. o open(std::string const &name): This member function prepares the FBB::LocalClientSocket object, constructed earlier using the default constructor, for use. The named Unix Domain socket is used to connect to the server using the named Unix Domain socket. An FBB::Errno is thrown if the socket could not be constructed. The construction of the socket does not mean that a connection has actually been established. In order to connect to the server, the member connect() should be used. EXAMPLE
See also the localserversocket(3bobcat) example. #include <iostream> #include <bobcat/localclientsocket> #include <bobcat/ifdstream> #include <bobcat/ofdstream> using namespace std; using namespace FBB; int main(int argc, char **argv) try { if (argc == 1) { cerr << "Provide filename representing the unix domain socket "; return 1; } LocalClientSocket client(argv[1]); int fd = client.connect(); string line; cout << "Connecting to socket " << fd << endl; IFdStream in(fd); // stream to read from OFdStream out(fd); // stream to write to while (true) { // Ask for a textline, stop if empty / none cout << "? "; if (!getline(cin, line) || line.length() == 0) return 0; cout << "Line read: " << line << endl; // Return the line to the server out << line.c_str() << endl; cout << "wrote line "; // Wait for a reply from the server getline(in, line); cout << "Answer: " << line << endl; } return 0; } catch (Errno const &err) { cerr << err.what() << " " << "Can't connect to " << argv[1] << ", port " << argv[2] << endl; return 1; } FILES
bobcat/localclientsocket - defines the class interface SEE ALSO
bobcat(7), ifdstream(3bobcat), ifdstreambuf(3bobcat), clientsocket(3bobcat), localserversocket(3bobcat), localsocketbase(3bobcat), ofd- stream(3bobcat), ofdstream(3bobcat) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::LocalClientSocket(3bobcat)