Sign in Join

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

Mailing lists / fpc-pascal / 2003-06

sockets (a beginer's question) (client-server)

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Ivan Petrov

Hello!

At first I have to send my thanks to Rainer Hantsch for my first question!
And then I beg your pardon for my bad english! I hope you'll understand me. so...oCrt is a very good unit !!!...and so easy to use!

But after a couple of days of testing diferent
example programs (from fpc docs),
I went to my second problem :-(

As you may guess I just start with linux programming...

The question:
Can I check if there is data pending in "sin" after I accept a connection and sin and sout streams are up.

This is because the program must do its main job until if an line comes in the sin stream, process it and then go back to main job.

...hard to explain... next time I'll use an english dictionary.

there must be a daemon which must be able to accept 1,2 or 3 tcp connections and react on them while the main job go.

there is an example in the doc, that I rewrote to accept lines. then I connect to it with telnet localhost <port> and when I enter "quit", server closes the connection, but when I'm "idle" the server _waits_ for my input. I don't want this.

any suggestions?

TIA!

Michael Van Canneyt
to Ivan Petrov
Ivan Petrov wrote 16 lines
Hello! At first I have to send my thanks to Rainer Hantsch for my first question! And then I beg your pardon for my bad english! I hope you'll understand me. so...oCrt is a very good unit !!!...and so easy to use! But after a couple of days of testing diferent example programs (from fpc docs), I went to my second problem :-( As you may guess I just start with linux programming... The question: Can I check if there is data pending in "sin" after I accept a connection and sin and sout streams are up.

You should use the select() call from the linux unit. This will check if data is available on some file descriptor. You can set a timeout.

Examples are provided in the documentation.

Michael.

Ivan Petrov
to Michael Van Canneyt

On Tuesday 10 June 2003 10:44, Michael Van Canneyt wrote:

--- snip ---

Show quoted text 11 lines
> The question: > Can I check if there is data pending in "sin" after I accept a connection > and sin and sout streams are up. You should use the select() call from the linux unit. This will check if data is available on some file descriptor. You can set a timeout. Examples are provided in the documentation. Michael.

Thank you. This leads me to the next question :)

I have read a lot of docs and sources.
and the only thing I found is a linux man page "$ man select". But this is for C programmers :-(
This was before a couple of hours before I see your mail...

And I want to ask where exactly is this implemented in free pascal ? I use version 1.0.6.

-------------------
Ivan Petrov

Ivan Petrov
to Michael Van Canneyt: You should use the select() call from the linux unit. This will check if data is…

Sorry for the spam!
Thank you! I found it.

But afterthe "Accept(S, FromName, Sin, Sout);"
how to tell to Select that I mean Sin as a parameter (file descriptor?) ? There are a LongInt and pointers in Select's definition...

Michael Van Canneyt wrote 8 lines
You should use the select() call from the linux unit. This will check if data is available on some file descriptor. You can set a timeout. Examples are provided in the documentation. Michael.
Unknown author
to Ivan Petrov
Ivan Petrov wrote 6 lines
Sorry for the spam! Thank you! I found it. But afterthe "Accept(S, FromName, Sin, Sout);" how to tell to Select that I mean Sin as a parameter (file descriptor?) ? There are a LongInt and pointers in Select's definition...

? Select works on a longint (file descriptor) or on a text file. What else do you need?

Michael.