egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Piped sockets under tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Sat Mar 03, 2007 2:44 pm    Post subject: Piped sockets under tcl Reply with quote

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
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Mar 04, 2007 12:33 am    Post subject: Reply with quote

Read about pipelines in the manpage for open:
http://www.tcl.tk/man/tcl8.4/TclCmd/open.htm
Back to top
View user's profile Send private message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Sun Mar 04, 2007 2:57 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Mar 04, 2007 3:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Sun Mar 04, 2007 5:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Mar 04, 2007 6:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Mar 04, 2007 7:12 pm    Post subject: Reply with quote

Perhaps user's code would help: socket api - nonblocking tcp made easy.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Sun Mar 04, 2007 9:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Mar 04, 2007 10:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Tue Mar 06, 2007 11:55 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Mar 06, 2007 1:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber