Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-03

reading a unix socket ? - this time without html

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Kenneth Due

Sorry about the 'spam'
I forgot to remove the html, before sending the mail..............

I have a problem reading a unix-socket

this snippet (from www.lirc.org) works, but it's in perl (I think) ........... :-(

        fd=socket(AF_UNIX,SOCK_STREAM,0);
        if(fd==-1)  {
                perror("socket");
                exit(errno);
        };
        if(connect(fd,(struct sockaddr *)&addr,sizeof(addr))==-1)  {
                perror("connect");
                exit(errno);
        };
        for(;;)  {
                i=read(fd,buf,128);
                if(i==-1)  {
                        perror("read");
                        exit(errno);
                };
                if(!i)  exit(0);
                write(STDOUT_FILENO,buf,i);
        };

What I would like is something like this :

Program reading_socket;
var
  data : string;
begin
  repeat
   data:=read_socket('/dev/lircd');
   < do something with data here >
  until keypressed; (until I daemonize it)
end.

Can anyone in here supply me with this ?
Kenneth Due

Unknown author
to Kenneth Due
Kenneth Due wrote
Sorry about the 'spam' I forgot to remove the html, before sending the mail.............. I have a problem reading a unix-socket

Please see the examples in the docs, they give examples of how to do this. The 'sockets' unit gives you everyting you need.

Michael.

Kenneth Due
to Unknown author
you wrote 14 lines
On Thu, 20 Mar 2003, Kenneth Due wrote: > Sorry about the 'spam' > I forgot to remove the html, before sending the mail.............. > > I have a problem reading a unix-socket Please see the examples in the docs, they give examples of how to do this. The 'sockets' unit gives you everyting you need. Michael.

That was the first place i looked
didn't find out anything there, tried the examples - didn't work
- obviously i'm to much of a newbie regarding unix and/or sockets. ;o)

still don't get it..............

Kenneth Due