using recv for nonblocking mode...in tcpip

I have a Server program, it works fine as a separate
executable, it uses recv() to receive any incoming
datas, this function blocks til it receive something.

Now, when i put the same code into a complicated
photon application under a Timer function, I need
to make recv() function nonblocking mode so TImer
will keep hitting. From the help, I used ioctl() functions as follows:
flag = 1 // to enable nonblocking
ioctl (sock, fiosnbio, &flag) before
the accept () function,
this works to make it nonblocking, but my tcpip
communication with my client is no longer established…

Do i need to put bind(), accept() function inside my timer function? in
another word, what do i need to do every time before receive any message
uing Recv()? re-bind, and re-accept?? I tried all that,
am I missing something else???
or there is no way to do it inside a timer …it has to be a separate
executable running in the background?

Another concern: if my timer runs slowly…would I
be running the risk of not receiving some of the message from my clients?
maybe putting in to a timer is a bad practice??

any help will be greatly appreciated!

Look at using a ‘Message Handler’ in your Photon app.
Look at the function : PtAppAddHandler().
Your message handler will receive process your incoming messages.

Ian.


“george” <gccst11@pitt.edu> wrote in message
news:a27td0$dpf$1@inn.qnx.com

I have a Server program, it works fine as a separate
executable, it uses recv() to receive any incoming
datas, this function blocks til it receive something.

Now, when i put the same code into a complicated
photon application under a Timer function, I need
to make recv() function nonblocking mode so TImer
will keep hitting. From the help, I used ioctl() functions as follows:
flag = 1 // to enable nonblocking
ioctl (sock, fiosnbio, &flag) before
the accept () function,
this works to make it nonblocking, but my tcpip
communication with my client is no longer established…

Do i need to put bind(), accept() function inside my timer function? in
another word, what do i need to do every time before receive any message
uing Recv()? re-bind, and re-accept?? I tried all that,
am I missing something else???
or there is no way to do it inside a timer …it has to be a separate
executable running in the background?

Another concern: if my timer runs slowly…would I
be running the risk of not receiving some of the message from my clients?
maybe putting in to a timer is a bad practice??

any help will be greatly appreciated!

Look at PtAppAddHandler - to add a message handler.

Ian.


“george” <gccst11@pitt.edu> wrote in message
news:a27td0$dpf$1@inn.qnx.com

I have a Server program, it works fine as a separate
executable, it uses recv() to receive any incoming
datas, this function blocks til it receive something.

Now, when i put the same code into a complicated
photon application under a Timer function, I need
to make recv() function nonblocking mode so TImer
will keep hitting. From the help, I used ioctl() functions as follows:
flag = 1 // to enable nonblocking
ioctl (sock, fiosnbio, &flag) before
the accept () function,
this works to make it nonblocking, but my tcpip
communication with my client is no longer established…

Do i need to put bind(), accept() function inside my timer function? in
another word, what do i need to do every time before receive any message
uing Recv()? re-bind, and re-accept?? I tried all that,
am I missing something else???
or there is no way to do it inside a timer …it has to be a separate
executable running in the background?

Another concern: if my timer runs slowly…would I
be running the risk of not receiving some of the message from my clients?
maybe putting in to a timer is a bad practice??

any help will be greatly appreciated!

george wrote:

I have a Server program, it works fine as a separate
executable, it uses recv() to receive any incoming
datas, this function blocks til it receive something.

Now, when i put the same code into a complicated
photon application under a Timer function, I need
to make recv() function nonblocking mode so TImer
will keep hitting. From the help, I used ioctl() functions as follows:
flag = 1 // to enable nonblocking
ioctl (sock, fiosnbio, &flag) before
the accept () function,

You need to be looking at select() (AKA PtAppAddFD()). This will allow
you to block awaiting a client connection, and at the same time handle
timer events.