* Socket vs File descriptor
@ 2009-09-24 6:51 KV Pavuram
2009-09-24 7:10 ` Willy Tarreau
2009-09-24 7:54 ` "YOSHIFUJI Hideaki (吉藤 英明)"
0 siblings, 2 replies; 3+ messages in thread
From: KV Pavuram @ 2009-09-24 6:51 UTC (permalink / raw)
To: linux-kernel
Hi,
Is there any ioctl call to determine if a given descriptor is a file descriptor or a socket descriptor.
Similarly, is there a way to find out a socket descriptor type ie.e if it is SOCK_STREAM, or SOCK_DGRAM type.
Thanks
Pav
See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz. http://in.buzz.yahoo.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Socket vs File descriptor
2009-09-24 6:51 Socket vs File descriptor KV Pavuram
@ 2009-09-24 7:10 ` Willy Tarreau
2009-09-24 7:54 ` "YOSHIFUJI Hideaki (吉藤 英明)"
1 sibling, 0 replies; 3+ messages in thread
From: Willy Tarreau @ 2009-09-24 7:10 UTC (permalink / raw)
To: KV Pavuram; +Cc: linux-kernel
On Wed, Sep 23, 2009 at 11:51:19PM -0700, KV Pavuram wrote:
> Hi,
>
> Is there any ioctl call to determine if a given descriptor is a file descriptor or a socket descriptor.
>
> Similarly, is there a way to find out a socket descriptor type ie.e if it is SOCK_STREAM, or SOCK_DGRAM type.
You should look at getsockopt(), getsockname(), etc... I'm pretty
sure that one of those will offer you exactly what you need. Also,
look at the error codes. Sometimes you can rely on them because you
have different types depending on whether the FD you point to is
not a socket or is a socket of invalid type.
Regards,
Willy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Socket vs File descriptor
2009-09-24 6:51 Socket vs File descriptor KV Pavuram
2009-09-24 7:10 ` Willy Tarreau
@ 2009-09-24 7:54 ` "YOSHIFUJI Hideaki (吉藤 英明)"
1 sibling, 0 replies; 3+ messages in thread
From: "YOSHIFUJI Hideaki (吉藤 英明)" @ 2009-09-24 7:54 UTC (permalink / raw)
To: KV Pavuram; +Cc: linux-kernel
KV Pavuram wrote:
> Is there any ioctl call to determine if a given descriptor is a file descriptor or a socket descriptor.
>
> Similarly, is there a way to find out a socket descriptor type ie.e if it is SOCK_STREAM, or SOCK_DGRAM type.
Maybe "lsof" command is your friend.
Or, depending on your purpose, you can use
getsockopt(), listen() etc. to get error
(e.g. ENOTSOCK) to test the type.
--yoshfuji
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-24 8:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 6:51 Socket vs File descriptor KV Pavuram
2009-09-24 7:10 ` Willy Tarreau
2009-09-24 7:54 ` "YOSHIFUJI Hideaki (吉藤 英明)"
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.