[En-Nut-Discussion] TCP/IP socket writing while waiting for data to read?

Harald Kipp harald.kipp at egnite.de
Mon Jul 4 08:55:29 CEST 2005


Sander,

Yes, it is possible to access the same socket from different
threads. Probably the memory leak is caused by another part
of your application.

Harald

At 12:19 29.06.2005 +0000, you wrote:
>Hello heroes,
>
>
>I'm using a modified version of the 'tcps' application for my own 
>application. Now, I have one thread that creates the socket, assigns a 
>stream if the socket and stream are created succesfull AND if a client is 
>connected, it sets a flag indicating that the connection has been made. 
>After that, this thread waits for incoming data using fgets.
>
>In the mean time another thread is writing data to the stream (but only 
>when the client connected flag is set). But this doesn't seem to work 
>well. Because it appears to me that it's not: memory leeks away, and 
>finally the telnet client is being disconnected. Now, I was wondering, is 
>it even possible to write data to a socket while another thread is waiting 
>for data on the same socket?
>
>Anyone got an answer to my question?
>
>Thanx in advance,
>Sander.
>
>PS: if it is not possible to both wait for data and write at 'the same 
>time', it would be a good idea to create two streams right? One for 
>reading, one for writing. But the problem is that, in that case i would 
>need 2 terminals to 2 different tcp ports, and this is not really what I'd 
>like.




More information about the En-Nut-Discussion mailing list