socket?(p1)
public
Returns true if the named file is a socket.
Show source
/*
* call-seq:
* File.socket?(file_name) => true or false
*
* Returns <code>true</code> if the named file is a socket.
*/
static VALUE
test_S(obj, fname)
VALUE obj, fname;
{
#ifndef S_ISSOCK
# ifdef _S_ISSOCK
# define S_ISSOCK(m) _S_ISSOCK(m)
# elif defined __BORLANDC__
# ifdef _S_IFSOCK
# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK)
# else
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK)
# endif
# endif
# else
# ifdef _S_IFSOCK
# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
# else
# ifdef S_IFSOCK
# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
# endif
# endif
# endif
#endif
#ifdef S_ISSOCK
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
if (S_ISSOCK(st.st_mode)) return Qtrue;
#endif
return Qfalse;
}