VB6: Winsock senddata problem - help! 
Author Message
 VB6: Winsock senddata problem - help!

I cannot understand the logic behind the winsock component!
I have an application that must communicate with another app via
WinSock messages. I have set up a test environment where I have a
simple Winsock "receive and display" application that shows what is
sent from my main app and immediately responds to the message.

The problem I have is that it seems like not all my messages actually
get transmitted! In principle I have this sequence triggered by the
click of a button in my application:
- Send message (sckClient.Senddata sMsg)
- Enter a wait loop for max 5 seconds waiting for a response. The loop
has a doevents inside.
- The socket DataArrival event receives the response and updates a
variable that will break the wait loop.

What actually happens is that the message sent is not received (hence
not transmitted) until after the wait loop exits and my error message
is posted. At this time my application reverts to idle state waiting
for user input.

So it seems to me that the WinSock component is not sending anything
out before the whole sequence initiated by the button click has
finished! Why is that so and how can I change it????
Note that I have put a lot of DoEvents here and there without any
change to this.

Bo Berglund
Software developer in Sweden

PGP: My public key is available at the following locations:
Idap://certserver.pgp.com
http://www.*-*-*.com/ :11371



Wed, 18 Jun 1902 08:00:00 GMT  
 VB6: Winsock senddata problem - help!
More strange findings:
The remote server is sending data to the application.
The DataArrival event is NOT fired!
More data are sent but DataArrival is still not fired.
Then the application itself sends a piece of data to the server and
now the DataArrival event fires and all of the preceding messages are
received!
Why is there a connection between the sending and receiving functions
like this???

Bo Berglund
Software developer in Sweden

PGP: My public key is available at the following locations:
Idap://certserver.pgp.com
http://pgpkeys.mit.edu:11371



Wed, 18 Jun 1902 08:00:00 GMT  
 VB6: Winsock senddata problem - help!
In article

Quote:

> More strange findings:
> The remote server is sending data to the
application.
> The DataArrival event is NOT fired!
> More data are sent but DataArrival is still not
fired.
> Then the application itself sends a piece of

data to the server and
Quote:
> now the DataArrival event fires and all of the

preceding messages are
Quote:
> received!
> Why is there a connection between the sending

and receiving functions
Quote:
> like this???

> Bo Berglund
> Software developer in Sweden

> PGP: My public key is available at the

following locations:

Quote:
> Idap://certserver.pgp.com
> http://pgpkeys.mit.edu:11371

I seem to be having a similar problem, except the
send seems to complete eventually without any
additional activity.  My server app responds to
several client apps.  The problem seems to occur
when it has to respond to several clients at
once.  I output debug messages which shows when
the Senddata occurs.  I also output debug
messages when the Send Complete Event fires.  The
Senddata's all get called.  The Send Complete
Event fires for 2 out of 3 clients.  Then about a
minute later, the last Send Complete fires.  I
just started researching this problem.
Hopefully, we'll find a solution soon!

Mike.

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VB6: Winsock senddata problem - help!

Quote:
> I seem to be having a similar problem, except the
> send seems to complete eventually without any
> additional activity.  My server app responds to
> several client apps.  The problem seems to occur

I was just glancing through when I saw this...
I had similiar problems as well.  I think its due to the fact that winsock
is somewhat blocking.
Even when you have multiple sockets controls on the form.  Try this instead.

Remove the control (ocx) from your tool box.  Go to program references and
browse for the component, but look for OCX,
look for MSWINSCK.OCX and add it.  Now you can code the control directly in
your own objects.

dim WithEvents ServerSocket as Winsock

set ServerSocket = new WinSock

Now you have the control directly inside your object, no need for a form.
Also add code in the error event of your sockets.  I found this to help as
well.

You might want to check out Catalyst.com for their socketwrench package...
Well written socket replacement that works (I think) better than winsock,
and it can use fast callback notifications rather than events (it can use
both).  When multiple sockets start responding, the slow event system looses
data (I think)

Hope this helps a little,
David



Wed, 18 Jun 1902 08:00:00 GMT  
 VB6: Winsock senddata problem - help!


Quote:
>> I seem to be having a similar problem, except the
>> send seems to complete eventually without any
>> additional activity.  My server app responds to
>> several client apps.  The problem seems to occur

>I was just glancing through when I saw this...
>I had similiar problems as well.  I think its due to the fact that winsock
>is somewhat blocking.
>Even when you have multiple sockets controls on the form.  Try this instead.

>Remove the control (ocx) from your tool box.  Go to program references and
>browse for the component, but look for OCX,
>look for MSWINSCK.OCX and add it.  Now you can code the control directly in
>your own objects.

>dim WithEvents ServerSocket as Winsock

>set ServerSocket = new WinSock

>Now you have the control directly inside your object, no need for a form.
>Also add code in the error event of your sockets.  I found this to help as
>well.

>You might want to check out Catalyst.com for their socketwrench package...
>Well written socket replacement that works (I think) better than winsock,
>and it can use fast callback notifications rather than events (it can use
>both).  When multiple sockets start responding, the slow event system looses
>data (I think)

>Hope this helps a little,
>David

 How do you put code in the events when you create the socket this
way?
There are no automatic generators availabe by selecting the component
and browsing the proceduer list, I guess.

Bo Berglund
Software developer in Sweden

PGP: My public key is available at the following locations:
Idap://certserver.pgp.com
http://pgpkeys.mit.edu:11371



Wed, 18 Jun 1902 08:00:00 GMT  
 VB6: Winsock senddata problem - help!
Try inserting the line:
DoEvents
after the SendData line. It only appears to send the data when the processor
is free.

Aidan
http://www.redrival.com/saturn/vbworld/

Quote:

> In article


> > More strange findings:
> > The remote server is sending data to the
> application.
> > The DataArrival event is NOT fired!
> > More data are sent but DataArrival is still not
> fired.
> > Then the application itself sends a piece of
> data to the server and
> > now the DataArrival event fires and all of the
> preceding messages are
> > received!
> > Why is there a connection between the sending
> and receiving functions
> > like this???

> > Bo Berglund
> > Software developer in Sweden

> > PGP: My public key is available at the
> following locations:
> > Idap://certserver.pgp.com
> > http://pgpkeys.mit.edu:11371

> I seem to be having a similar problem, except the
> send seems to complete eventually without any
> additional activity.  My server app responds to
> several client apps.  The problem seems to occur
> when it has to respond to several clients at
> once.  I output debug messages which shows when
> the Senddata occurs.  I also output debug
> messages when the Send Complete Event fires.  The
> Senddata's all get called.  The Send Complete
> Event fires for 2 out of 3 clients.  Then about a
> minute later, the last Send Complete fires.  I
> just started researching this problem.
> Hopefully, we'll find a solution soon!

> Mike.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. winsock problem sending large strings (winsock.senddata)

2. WInsock SendData problem HELP

3. winsock senddata problem/question

4. Winsock.SendData Problem

5. problem with winsock.senddata

6. Visual Basic Winsock senddata problem

7. Winsock TCP SendData problem

8. problem with WINSOCK.SENDDATA

9. Winsock SendData problems

10. Winsock SendData Problem?

11. Winsock SendData problem

12. senddata method problem in winsock control

 

 
Powered by phpBB® Forum Software