| View previous topic :: View next topic |
| Author |
Message |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Sat Mar 03, 2007 2:44 pm Post subject: Piped sockets under tcl |
|
|
How do I create a named pipe instead of creating a socket to listen on. I've been searching google, looking through the manual, but I can't find anything about named pipes. _________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Sun Mar 04, 2007 2:57 pm Post subject: |
|
|
As far as I know is what you're suggesting only for execution.
| Code: | | open "|/path/to/binary" r+ |
not to make named pipes (sockets)
such as /tmp/mysql.sock, for example, or would you be so kind explain yourself, .. _________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Mar 04, 2007 3:48 pm Post subject: |
|
|
Been a while since I played around with named pipes, but as I recall you create them with 'mknod' or 'mkfifo' and then just use them as regular files:
Example using two concurrent shell-sessions:
Session 1
| Code: | bash$ mknod /home/myhome/test.fifo
bash$ ls -l > /home/myhome/test.fifo |
Session 2
| Code: | bash$ cat /home/myhome/test.fifo
-rwxr--r-- 1 nml375 nml375 16896 26 maj 2006 network.doc
-rw-rw-r-- 1 nml375 nml375 1927 11 okt 2005 private-root-pem.crt
... |
Should'nt be much different with tcl..
Or where you thinking of unix sockets? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Sun Mar 04, 2007 5:53 pm Post subject: |
|
|
i was thinking of making a script listen on a unix socket.
like:
| Code: | | socket -server myproc localhost 1234 |
_________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Mar 04, 2007 6:52 pm Post subject: |
|
|
As far as I know, there is no support for unix sockets in tcl.
Also, keep in mind that "named pipes" is something completely different from "unix sockets", where the first one uses simple file I/O for communications while the second makes use of the kernels support for socket communication, with the domain AF_UNIX rather than AF_INET (which is used for IP sockets).
I suppose IP sockets won't cut it for you?
If you really want unix sockets, you'd have to create some wrapping-code to provide the function calls from the socket-library to the tcl-environment (possibly by creating an eggdrop module).
One option, I guess, would be to write your project entirely as a module rather than a tcl-script. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Sun Mar 04, 2007 9:16 pm Post subject: |
|
|
I know how to use sockets, it's just that i want a to create a unix socket.
ok it's
| Code: | | socket -server myproc -myaddr 127.0.0.1 1234 |
So I assume it's not possible.
i think maybe mknod might do.. _________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Mar 04, 2007 10:48 pm Post subject: |
|
|
Keep in mind that named pipes are "one-way connections", that is, one client must open the fifo in readonly mode, and other client in writeonly mode.
Btw, if you wanted to work with unix socket, why were you asking for named pipes? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Tue Mar 06, 2007 11:55 am Post subject: |
|
|
I asked for a named pipe which functioned as a socket, UNIX sockets I suppose.
i want to be able to '|' pipe data from syslogd to a script.
but since reading from stdin is having some issues.. i wanted to use pipes instead. _________________ XplaiN but think of me as stupid |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Mar 06, 2007 1:56 pm Post subject: |
|
|
Pipes and sockets (IP/IPX/Unix/etc all alike) are two completely different concepts, hence there is no "named pipe with socket functions" (unix or otherwize).
Pipes are used just like any other file-stream, whereas sockets have a far more complex structure.
As for your intent to send data from syslogd; a quick check in the manual page would reveal that syslogd allows files, ip/udp, and named pipes to be destination for logmessages. It does not, however, support unix sockets as destination. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|