Get the file descriptor of a socket file. C vs Python.
Hi,
I want to validate that a file is a socket file on Linux. I know I can do this using the S_ISSOCK macro, but I am not sure how to get the file descriptor for the socket file.
For example, I know that /tmp/mapping-foo is a socket file. In Python I can do something like this:
How ever in C, I am unable to get the file descriptor for the file /tmp/mapping-foo. I tried using open, fopen and fileno as follows:
But, I am getting this error message:
I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Hi Friends,
I have written a program which will listener for more than 1000 requests per second from a single socket descriptor and then it will process those requestes. Its taking X amount of time. Now i want to reduce that time. Will I can write multiple threads to receive the... (2 Replies)
Hello All,
Im opening a file desciptor in perl and sending data using print CMD "$xyz".
is there a limit to the length of the string that I can give to this CMD at a time. (3 Replies)
I have a query related to the functioning of poll() system call on solaris and linux platforms.
When the client is abnormally terminated, it is observed that on Linux the socket is immediately closed and the server gets ECONNREFUSED.
But in case of Solaris it is observed that the socket is not... (0 Replies)
hi....,
can anyone tell me what is the exact difference between file descriptor and file pointer...... and why file descriptor takes integer value???:confused: (10 Replies)
Hi ,
i have two basic requirement on linux platform . I am using C language to do this .
1) copying one file to another (assuming i know their file descriptors)
2) Overwriting a file using it file descriptor .
Please guide.
regards
Aki (2 Replies)
I am trying to write a script which will only show me the file descriptor count for a process/pid. My script will return me the count only not the whole output. For example, I would like my script to return the output 23 this case, not the whole output.
Can anybody please help me how do I get... (11 Replies)
I have BIND 9.8.1-P1 cache only DNS server running in Solaris 10. I have upgraded the same from 9.6.1 to 9.8.1-P1. Now i am facing "file descriptor exceeds limit (4096/4096)" error frequently on the server.
Please help me on this issue! (1 Reply)
Discussion started by: sandeep.tk
1 Replies
LEARN ABOUT OSF1
sockatmark
sockatmark(3) Library Functions Manual sockatmark(3)NAME
sockatmark - Tests whether a socket is at the out-of-band mark
LIBRARY
Standard C Library: (libc.so, libc.a)
SYNOPSIS
#include <sys/socket.h>
int sockatmark (int socket);
STANDARDS
The sockatmark function also supports POSIX.1g Draft 6.6.
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Specifies the file descriptor associated with a socket.
DESCRIPTION
The sockatmark() function enables applications to determine which received data precede the out-of-band data and which data follow the out-
of-band data. The function uses the file descriptor for the socket to locate the data. Applications typically use this function between
receive operations.
The sockatmark() function does not remove the mark from the stream.
RETURN VALUES
Upon successful completion, the sockatmark() function returns 1 if the protocol has marked the data stream and all data preceding the mark
have been read, or 0 (zero) if there is no mark or if data precede the mark in the receive queue.
If the sockatmark() function fails, a value of -1 is returned and errno is set to indicate the error.
ERRORS
If the sockatmark() function fails, errno may be set to one of the following values: The socket parameter is not a valid file descriptor.
The socket parameter does not specify a descriptor for a socket.
RELATED INFORMATION
Functions: recv(2), recvmsg(2).
Standards: standards(5). delim off
sockatmark(3)