Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disparities Writing to sockets between Client and Server 2

Status
Not open for further replies.

JohnStep

Programmer
Apr 19, 2000
190
US
  I am writing a program where as a server communicates to a client. The problem I am having is that the Server will send data though the network to the client, some of the data will not be read by the client. It seems the server is writing to the socket too fast and the Client is not reading each read_event that it is sent. Can this be possible. The server hardware I am using is somewhat faster then the Client hardware could this cause the communication disperity. I know the read-write work cause it works sometimes and others it writes but the client fails to read. Any Ideas would be appreciated...   John Stephens
 
John,<br><br>On the sending side - are you making sure your send completes before you send something else? I had a similar problem and fixed it like that, there's a property of the MS Winsock control that lets you see whether it's busy or not (can't remember what it is, sorry) and I ended up looping until the control wasn't busy each time I did something.<br><br>Shout up again if this doesn't help.<br><br>Regards<br> <p>Mike<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>Please don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
Thanks for the information Mike. You just confirmed my suspicions. I noticed if I added a for-next loop in between the socket.write the data would go through correctly. I just did'nt know if it was the server or client side. Now I have a way to look. Thanks again!!!<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sincerely,<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;John Stephens
 
The property is ' state '. I ran it on the socket that is in question and it came back with a 'Socket Idle' meaning the socket was not currently receiving /sending data. Like You said the only way to get all the data accross is to enter a time delay:<br><br>&nbsp;&nbsp;&nbsp;for x=1 to 300<br>&nbsp;&nbsp;&nbsp;debug.print x<br>&nbsp;&nbsp;&nbsp;next x<br><br>&nbsp;And this will clear it up. But obviously when you compile the software having a &quot;debig.print&quot; is not acceptable. So any ideas on a time delay. If I keep a statement out between the for-next it still will not send the data. The mid statement is essential in order to delay long enough to send data. I thought about using a timer , but the program is timer orientated and I cannot really afford to use one just for a wait command.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;John Stephens
 
I would do something like: (writing this off the top of my head, no idea if it will compile)<br><br>StopTime = Now() + 5&nbsp;&nbsp;'5 seconds into future<br>OKToSend = false<br><br>while (true) <br>&nbsp;&nbsp;&nbsp;&nbsp;OKToSend = iif(socket.state = socketidle, true, false)<br>&nbsp;&nbsp;&nbsp;&nbsp;if OKToSend or (now() &gt; StopTime) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit while<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;Do Events&nbsp;&nbsp;&nbsp;'Optional<br>wend<br>if not OKToSend then<br>&nbsp;&nbsp;&nbsp;&nbsp;'Timed out<br>&nbsp;&nbsp;&nbsp;&nbsp;exit sub<br>end if<br><br>This will loop for up to 5 seconds waiting for the socket to become available.<br><br>Chip H.<br><br>
 
try<br><br><FONT FACE=monospace><b><br>sck.Write SomeData<br>While sck.State &lt;&gt; Idle ' that's not the right constant, I know<br>&nbsp;&nbsp;&nbsp;&nbsp;DoEvents<br>Wend<br>sck.Write NextChuckOfData<br></font></b><br> <p>Mike<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>Please don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top