Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of Pipe Types in a dll

Status
Not open for further replies.

pecan204

Programmer
Jan 25, 2001
24
0
0
US
Can anyone help?

I have a dll that establishes a pipe that will obtain data from another program. Currently it is setup to continually listen for new data and then get itfrom another program.

Is it possible upon the call to the dll to create the pipe connection, get the data, and close each time? It would essentially be getting rid of the do while loop. The call to the dll to get the data could occur once every second.

If the below code is not the best route to do this would TransactNamedPipe be better? Or are there other suggestions?

Thanks

pipe = CreateFile( "\\\\.\\pipe\\ssguipipe"C, &
IOR(GENERIC_WRITE , GENERIC_READ) , &
IOR(FILE_SHARE_READ , FILE_SHARE_WRITE), &
NULL_SECURITY_ATTRIBUTES, &
OPEN_EXISTING, &
FILE_FLAG_OVERLAPPED, &
DEFAULT )

do while(.TRUE.)
if(ReadFile(pipe,LOC(pipebuf),1024 ,LOC(inlen),NULL_OVERLAPPED).eqv. .TRUE.)then
!write(*,*)'so far so good'
firstpos = SCAN(pipebuf,'@')
lastpos = SCAN(pipebuf,'$')
!write(*,*)pipebuf(firstpos+1:lastpos-1)
read(pipebuf(firstpos+1:lastpos-1),*)Dat1(1),Dat1(2),Dat1(3),Dat1(4),Dat1(5),Dat1(6),Dat1(7),Dat1(8),Dat1(9),Dat1(10),Dat1(11),Dat1(12)
else
write(*,*)'disconnected'
stop
end if
end do

 
Looks like Fortran but never mind: the principle is the same. Why not put it on a separate thread then that thread can poll forever while your main thread gets on with its life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top