[fpc-pascal]reading a unix socket ? - this time without html

Kenneth Due kenneth at computercafeen.dk
Thu Mar 20 17:18:36 CET 2003


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

kenneth at skummel.dk
kenneth at computercafeen.dk




More information about the fpc-pascal mailing list