[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Henning

11/29/2011 10:22:00 PM

Hi grp,

I have tried to find some info, but can't find/understand.

I have an app that receives packets thru a Socket_OnDataArrival.
This calls a Sub that handles the packets.

What happens if one or more packets are received while handling the first
one?
What happens when the first packet is done, and the Sub Exits?

I would appreciate if someone could clarify this. My only place to test is
in the running sharp app. handling alarms... Missing any packet would be a
problem.

TIA /Henning


6 Answers

ralph

11/30/2011 12:03:00 AM

0

On Tue, 29 Nov 2011 23:22:13 +0100, "Henning"
<computer_hero@coldmail.com> wrote:

>Hi grp,
>
>I have tried to find some info, but can't find/understand.
>
>I have an app that receives packets thru a Socket_OnDataArrival.
>This calls a Sub that handles the packets.
>
>What happens if one or more packets are received while handling the first
>one?
>What happens when the first packet is done, and the Sub Exits?
>
>I would appreciate if someone could clarify this. My only place to test is
>in the running sharp app. handling alarms... Missing any packet would be a
>problem.
>
>TIA /Henning


Assuming that is an Event - Events are queued. So when the code
defined for the Event is finished, VB will handle the next Event in
the queue. This will not necessarily be a Data Arrival event, but
eventually all will be handled.

You didn't say which control, so I'm assuming it is buffered.

If it is a Callback, then you might consider simply prioritizing the
data and launching your own events, exiting the sub as soon as
possible. (Rare)

It is normally very straight-forward and simple, but service levels
and requirements may need additional attention.

More information would be nice.

-ralph

Mayayana

11/30/2011 12:12:00 AM

0

I've never used the Winsock control, but when using
sockets directly one calls recv, providing a pointer to
a data buffer, when data arrival notification is received.
The incoming data is being buffered by Windows
sockets, so it's not lost.

When the connection closes one calls recv again to get
whatever might be left in the buffer. I assume it's a
similar case with the winsock control. In other words, it's
not like the remote server is spitting data and you have
to catch it.
--
--
"Henning" <computer_hero@coldmail.com> wrote in message
news:jb3lum$h2$1@dont-email.me...
| Hi grp,
|
| I have tried to find some info, but can't find/understand.
|
| I have an app that receives packets thru a Socket_OnDataArrival.
| This calls a Sub that handles the packets.
|
| What happens if one or more packets are received while handling the first
| one?
| What happens when the first packet is done, and the Sub Exits?
|
| I would appreciate if someone could clarify this. My only place to test is
| in the running sharp app. handling alarms... Missing any packet would be a
| problem.
|
| TIA /Henning
|
|


Henning

11/30/2011 12:42:00 AM

0


"ralph" <nt_consulting64@yahoo.net> skrev i meddelandet
news:flrad71its1gsfvf64aosmphsgkecntgb0@4ax.com...
> On Tue, 29 Nov 2011 23:22:13 +0100, "Henning"
> <computer_hero@coldmail.com> wrote:
>
>>Hi grp,
>>
>>I have tried to find some info, but can't find/understand.
>>
>>I have an app that receives packets thru a Socket_OnDataArrival.
>>This calls a Sub that handles the packets.
>>
>>What happens if one or more packets are received while handling the first
>>one?
>>What happens when the first packet is done, and the Sub Exits?
>>
>>I would appreciate if someone could clarify this. My only place to test is
>>in the running sharp app. handling alarms... Missing any packet would be a
>>problem.
>>
>>TIA /Henning
>
>
> Assuming that is an Event - Events are queued. So when the code
> defined for the Event is finished, VB will handle the next Event in
> the queue. This will not necessarily be a Data Arrival event, but
> eventually all will be handled.
>
> You didn't say which control, so I'm assuming it is buffered.
>
> If it is a Callback, then you might consider simply prioritizing the
> data and launching your own events, exiting the sub as soon as
> possible. (Rare)
>
> It is normally very straight-forward and simple, but service levels
> and requirements may need additional attention.
>
> More information would be nice.
>
> -ralph

Hi Ralph,

Yes it is an Event, because it is a service, I'm using CSocketMaster,
winsock only works on a form afaik.

So, when the current event is finished, I will, if there has been another
data receive, a new event-trigg. If that is how it works, I will not have at
least this problem...

Thanx!
/Henning


Henning

11/30/2011 12:50:00 AM

0

Hi Mayayana,

The connection is kept open as long as both sides are living, I'm sending a
HeartBeat pkt to the alarmserver every 5 sec.. The alarserver expects a HB
within 8 sec. or it closes the connection.

Thanx!
/Henning


"Mayayana" <mayayana@invalid.nospam> skrev i meddelandet
news:jb3s99$c44$1@dont-email.me...
> I've never used the Winsock control, but when using
> sockets directly one calls recv, providing a pointer to
> a data buffer, when data arrival notification is received.
> The incoming data is being buffered by Windows
> sockets, so it's not lost.
>
> When the connection closes one calls recv again to get
> whatever might be left in the buffer. I assume it's a
> similar case with the winsock control. In other words, it's
> not like the remote server is spitting data and you have
> to catch it.
> --
> --
> "Henning" <computer_hero@coldmail.com> wrote in message
> news:jb3lum$h2$1@dont-email.me...
> | Hi grp,
> |
> | I have tried to find some info, but can't find/understand.
> |
> | I have an app that receives packets thru a Socket_OnDataArrival.
> | This calls a Sub that handles the packets.
> |
> | What happens if one or more packets are received while handling the
> first
> | one?
> | What happens when the first packet is done, and the Sub Exits?
> |
> | I would appreciate if someone could clarify this. My only place to test
> is
> | in the running sharp app. handling alarms... Missing any packet would be
> a
> | problem.
> |
> | TIA /Henning
> |
> |
>
>


(nobody)

11/30/2011 4:23:00 PM

0

"Henning" <computer_hero@coldmail.com> wrote in message
news:jb3lum$h2$1@dont-email.me...
> Hi grp,
>
> I have tried to find some info, but can't find/understand.
>
> I have an app that receives packets thru a Socket_OnDataArrival.
> This calls a Sub that handles the packets.
>
> What happens if one or more packets are received while handling the first
> one?
> What happens when the first packet is done, and the Sub Exits?
>
> I would appreciate if someone could clarify this. My only place to test is
> in the running sharp app. handling alarms... Missing any packet would be a
> problem.

Like others suggested, you won't get another event unless you are yielding
control such as by using DoEvents or MsgBox(including in an error handler).
Timer events don't fire in the middle of events, unless again you are using
DoEvents or MsgBoxes.

Also, the Winsock API doesn't trigger another receive event(See FD_READ
under WSAAsyncSelect() help) until you call GetData(recv() function). At
that moment, the Winsock API will send your app another receive event which
will be placed in the message queue, and will be processed when the current
event exits, or when you relinquish control by using DoEvents or MsgBoxes.
This also means that you don't get receive events for each send, but you
could get one for multiple or partial sends.

Your 8 seconds maybe too short for busy servers, I am not sure. You maybe
receiving two heartbeats, or 0.5 heartbeats, or 1.5 heartbeats(assuming that
a heartbeat is more than one byte). It depends. You need to make sure that
your routine can handle these situations. Try testing your parsing routine
with a byte array that you fragment in different ways, to make sure that it
handles all situations correctly, rather than testing it on live data,
because you may not see all these situations when testing. I did that with
my routine, and it saved me a lot of future troubleshooting.



James Tyler

11/30/2011 5:56:00 PM

0

If your socket depends on events to take next step, you must put in
DoEvents.
Consider the following snippet. It only send out to 1 PC if tou leave out
the Doevents.
This may not apply to the OP. But anyway...



Public Sub SendMsg(Msg As String)
Dim i As Long
m_Msg = Msg
For i = 0 To g_HostsCount - 1
With sckSender
.Close
.RemoteHost = g_Hosts(i)
.RemotePort = g_TCP_PORT
.Connect ' on connected, _Connect event
will send
DoEvents ' must do this
End With
Next
End Sub

Private Sub sckSender_Connect()
sckSender.SendData m_Msg
End Sub