TCP/IP and multithreading

hello!
I have some problems with TCP/IP function and threads. I have a process
(C++) that starts a QNX-server. It sends and receives messages to/from a
WinNT-client. It spawns three threads:
the first one starts the server and waits for its death;
the second waits on the “recv” function for messages from the client
the third is in charge to send messages to the client.
The three threads share the same variables. When the client is connected, in
the first thread the function “accept” works well returning a good
descriptor ‘ServerSock’ , but in the second one the function
“recv(ServerSock,…)” returns -1 with error “bad file descriptor”. I have
checked that the parameter ‘ServerSock’ used in the second thread is the
same as the return value of ‘accept’ called in the first thread.
Do you have some suggestions? Could the socket library of QNX be not
multithreading?
thanks,
mascia.

Under QNX4 the TCP/IP stack is NOT multi-thread.

Under NTO I don’t know.

“lazzarini” <lazzarini.m@tecnomare.it> wrote in message
news:8pi7qo$h17$1@news.IT.net

hello!
I have some problems with TCP/IP function and threads. I have a
process
(C++) that starts a QNX-server. It sends and receives messages to/from a
WinNT-client. It spawns three threads:
the first one starts the server and waits for its death;
the second waits on the “recv” function for messages from the client
the third is in charge to send messages to the client.
The three threads share the same variables. When the client is connected,
in
the first thread the function “accept” works well returning a good
descriptor ‘ServerSock’ , but in the second one the function
“recv(ServerSock,…)” returns -1 with error “bad file descriptor”. I have
checked that the parameter ‘ServerSock’ used in the second thread is the
same as the return value of ‘accept’ called in the first thread.
Do you have some suggestions? Could the socket library of QNX be not
multithreading?
thanks,
mascia.

In article <8pi7qo$h17$1@news.IT.net>,
lazzarini <lazzarini.m@tecnomare.it> wrote:

hello!
I have some problems with TCP/IP function and threads. I have a process
(C++) that starts a QNX-server. It sends and receives messages to/from a
WinNT-client. It spawns three threads:
the first one starts the server and waits for its death;
the second waits on the “recv” function for messages from the client
the third is in charge to send messages to the client.
The three threads share the same variables. When the client is connected, in
the first thread the function “accept” works well returning a good
descriptor ‘ServerSock’ , but in the second one the function
“recv(ServerSock,…)” returns -1 with error “bad file descriptor”. I have
checked that the parameter ‘ServerSock’ used in the second thread is the
same as the return value of ‘accept’ called in the first thread.
Do you have some suggestions? Could the socket library of QNX be not
multithreading?
thanks,
mascia.
\

Are you talking about QNX4 or Neutrino? If you are using QNX4 tfork,
you should be aware that file descriptors obtained after spawning
a thread aren’t shared by that thread. This has been discussed
repeatedly in this forum with respect to tfork.

If it’s Neutrino, some more information would help in determining what is
happening.

Steve Furr email: furr@qnx.com
QNX Software Systems, Ltd.

Hi,
thanks for the answers.
We are using QNX 4.25

Are you talking about QNX4 or Neutrino? If you are using QNX4 tfork,
you should be aware that file descriptors obtained after spawning
a thread aren’t shared by that thread. This has been discussed
repeatedly in this forum with respect to tfork.

We use _beginthread to launch threads.

We suppose that it is better to use different processes instead different
threads
if these threads are using the same socket descriptor. Correct?

Thanks a lot

Mascia

“GRASSO Tiberio” <grasso.t@tecnomare.it> wrote in message
news:8plbit$q1i$1@news.IT.net

Hi,
thanks for the answers.
We are using QNX 4.25

Are you talking about QNX4 or Neutrino? If you are using QNX4 tfork,
you should be aware that file descriptors obtained after spawning
a thread aren’t shared by that thread. This has been discussed
repeatedly in this forum with respect to tfork.


We use _beginthread to launch threads.

We suppose that it is better to use different processes instead different
threads

Under QNX4 a thread is a actually a process. From the kernal/performance
point of view their is no difference.

if these threads are using the same socket descriptor. Correct?

It’s not that it’s better, you can not share the same socket descriptor.

Thanks a lot

Mascia