Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

Socket in multithreading (1 reply)

$
0
0
Hi!
Do someone use sockets in multithreading? I am trying to implement bidirectional socket connection with simultaneous reading/writing operation. There are two threads - one for reading and one for writing. The code is very simple (just schematic):

BUTTON Clicked Process
// Place data when buttons is clicked
PlaceSomeDataInSendingQueue()

...
// Sending procedure
PROCEDURE Sending

SocketConnect("SOCK",Port,"IP")
...
LOOP
  Data is string = TakeSomeDataFromSendingQueue()
  CriticalSectionStart()
  SocketWrite("SOCK","data")
    CriticalSectionEnd()
END

// Reading procedure
PROCEDURE Reading

...
LOOP
  CriticalSectionStart()
  Data is string = SocketRead("SOCK",False)
  CriticalSectionEnd()
  IF Data = "" THEN CONTINUE
END

On the server side I see only the first connection (1st click of button)... then no connections. Writing to socket is executing without error... so it seems the data is written but where I don't know. Any ideas?

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>