Tag Info

Hot answers tagged

13

A socket is just a logical endpoint for communication. They exist on the transport layer. You can send and receive things on a socket, you can bind and listen to a socket. A socket is specific to a protocol, machine, and port, and is addressed as such in the header of a packet. Beej's guides to Network Programming and Inter-Process Communication both have ...


13

According to the author of lsof, it's impossible to find this out: the Linux kernel does not expose this information. Source: 2003 thread on comp.unix.admin. The number shown in /proc/$pid/fd/$fd is the socket's inode number in the virtual socket filesystem. When you create a pipe or socket pair, each end successively receives an inode number. The numbers ...


13

That's the inode number for the pipe or socket in question. A pipe is a unidirectional channel, with a write end and a read end. In your example, it looks like FD 5 and FD 6 are talking to each other, since the inode numbers are the same. (Maybe not, though. See below.) More common than seeing a program talking to itself over a pipe is a pair of separate ...


9

For sockets you can find more information about the inode in /proc/net/tcp, /proc/net/udp or /proc/net/unix. For example: ls -l /proc/<pid>/fd lrwx------ 1 root root 64 May 26 22:03 3 -> socket:[53710569] We see inode is 53710569. head -n1 < tcp ; grep -a 53710569 tcp sl local_address rem_address st tx_queue rx_queue tr tm->when ...


8

As recommended by IBM: use lsof -i -n and look for port XY. If you want parseable output from lsof, use the -F flag and parse the output with awk. You can get pre-compiled binaries for AIX V5. I don't know if there are pre-compiled binaries for V6; if there aren't, get the source and compile it.


8

These are abstract sockets, that live outside the filesystem namespace. netstat --unix, lsof -U and other commands print an @ sign instead of the nul byte that's at the start of the pathname.


7

UNIX domain sockets and FIFO may share some part of their implementation but they are conceptually very different. FIFO functions at a very low level. One process writes bytes into the pipe and another one reads from it. A UNIX domain socket has the same behaviour than a TCP/IP socket. A socket is bidirectionnal and can be used by a lot of processes ...


7

What and where is file per each socket? "Everything" is an exaggeration. It's not a strict policy, it's just a common practice to use the filesystem for interfaces since filesystem access is synonymous with system calls (i.e., the filesystem is really an interface with the kernel, and so provides a convenient format for all kinds of things). Other ...


6

It's part of the TCP (or UDP, etc.) header, in the packet. So the server finds out because the client tells it. This is similar to how it finds out the client's IP address (which is part of the IP header). E.g., every TCP packet includes an IP header (with source IP, destination IP, and protocol [TCP], at least). Then there is a TCP header (with source and ...


6

Since you are programming in C I thought of posting a little snippet which shows you if the port is open or not, I have programmed to output a string. You can easily change it to fit your need. Answer to your second question, like everyone here said, you can pretty much use any port if you are the super user (root) on the system if the port is not used by ...


5

/etc/services is only used for service name resolution. Unless you want to refer to your port by name, there's no need to update the file. However, you might want to add it anyway, if only for your own sanity. A few things you might want to consider when selecting your port number: Only root can bind to a port <1024. This is to protect sensitive ...


5

I believe that the idea of the socket being unavailable to a program is to allow any TCP data segments still in transit to arrive, and get discarded by the kernel. That is, it's possible for an application to call close(2) on a socket, but routing delays or mishaps to control packets or what have you can allow the other side of a TCP connection to send data ...


5

They are commonly found in /tmp or a subdirectory thereof. Note that everything in /tmp is subject to erasure at shutdown -- not that it necessarily is erased, just beware that it can be, so if you use that, check if you have to create your subdirectory each time. You will want to use a subdirectory if you want to restrict access via permissions, since ...


5

UNIX domain sockets should offer better performance than TCP sockets over loopback interface (less copying of data, fewer context switches). Beware though that sockets are only reachable from programs that are running on the same server (there's no network support, obviously) and that the programs need to have the necessary permissions to access the socket ...


5

No the data never leaves the box when it's addressing an IP address that's assigned to a local interface. You can convince yourself of this fact by using traceroute to confirm. Example Here's my wireless NIC on my Fedora 19 system. $ ip -4 addr show wlp3s0 | grep inet inet 192.168.1.20/24 brd 192.168.1.255 scope global wlp3s0 It's assigned the IP ...


5

According to the coreutils documentation under --classify (alias -F), = is for sockets: Append a character to each file name indicating the file type. Also, for regular files that are executable, append ‘*’. The file type indicators are ‘/’ for directories, ‘@’ for symbolic links, ‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors, and nothing for regular ...


5

man 7 unix: The AF_UNIX (also known as AF_LOCAL) socket family is used to communicate between processes on the same machine efficiently. Traditionally, UNIX domain sockets can be either unnamed, or bound to a file system pathname (marked as being of type socket). Linux also supports an abstract namespace which is independent of the file system. ...


5

A socket is a file. But not all files have names. Here are a few examples of files that don't have names: Any file that used to have a name, and is now deleted, but is still opened by a program. An unnamed pipe, such as one created by the | shell operator. Most sockets: any Internet socket, or a Unix socket which is not in the filesystem namespace (it can ...


4

by default NFS is enabled you can remove packages: apt-get --purge remove nfs-kernel-server nfs-common portmap or stop services temporary: /etc/init.d/portmap stop /etc/init.d/nfs-kernel-server stop or stop them permanently: service portmap stop service nfs-kernel-server stop


4

Technically, there's no such thing as a "reserved port". In TCP/UDP, the only way to "reserve" a port is to actually bind() a socket to it. A bound port will not be used by other applications; an unused port is, well, unused so other applications are free to use it. If you are writing server software, then you can bind your sockets to specific ports as ...


4

The normal port for an rsh server is 514. Your rsh client supports Kerberos, and a Kerberos-enabled rsh server normally listens on port 544. Your rsh client first tries to log in with Kerberos authentication, probably first with Kerberos version 5 then with Kerberos version 4 (“krb4” for short). The error “connection refused” is due to the absence of a ...


4

Do they point to some property of the resource? Yes. They're a unique identifier that allows you to identify the resource. Also why are some of the links broken? Because they're links to thinks that don't live in the filesystem, you can't follow the link the normal way. Essentially, links are being abused as a way to return the resource type and ...


4

Assuming you're talking C/C++, use setsockopt() and SO_REUSEADDR. This allows reuse as long as there is no active process listening to that port. Edit: The reason it is still in use is you didn't close the socket down appropriately. You Control-C killed it. You can use netstat to see the ports that are open or not quite closed yet. ...


4

There are several ways, the most common probably being: # netstat -ltun You can, of course, grep for other (regular) expression. If you are using different machines (client and server), you need to check iptables as well. You can pretty much use any port that's not currently being used for your programs. Check, however, /etc/services for known and ...


3

Try using netstat with rmsock. port=$1 addr=`netstat -Aan | grep $port | awk '{print $1}` pid=`rmsock $addr tcpcb | awk '{print $9}'` ps -ef | grep $pid For netstat, the -A shows the address of any protocol control blocks associated with the sockets, the -a option shows the state of all sockets including those of server processes, and the -n option gives ...


3

You didn't say what type of sockets. Stream sockets You can send (by definition) an unlimited amount of data. If it cannot all be buffered or sent at once or if the receiver cannot receive it all at once, the send will either block (for blocking sockets) or return a partial count of bytes written or EAGAIN (for nonblocking sockets). Datagram sockets It ...


3

Are you running anything that provides a daytime service? From Wikipedia: On UNIX-like operating systems a daytime server is usually built into the inetd (or xinetd) daemon. The service is usually not enabled by default. It may be enabled by adding the following lines to the file /etc/inetd.conf and telling inetd to reload its configuration. daytime ...


3

Need not, they're there by reason — «… The purpose of TIME-WAIT is to prevent delayed packets from one connection being accepted by a later connection …» Linux also has net.ipv4.tcp_tw_recycle and net.ipv4.tcp_tw_reuse which can be helpful. Another tool to mention is linux-tcp-drop


3

A socket an abstraction. It provides a interface for applications to utilize a system resource (in this case the network connection) in a way that allows the operating system to mediate and organize the use of a limited resource by any number of applications. If the data being sent through the socket could be thought of as envelopes of mail, then the socket ...


3

You can't do this for the same reason you can't access the memory of an unrelated process, because a file descriptor is part of the memory of another process. The only reason there's information about stuff like this in /proc is because the kernel provides it there, and it is read-only (thus there are means to examine a copy of process memory). If it ...



Only top voted, non community-wiki answers of a minimum length are eligible