Winsock what did I miss? - basic.visual
This is a discussion on Winsock what did I miss? - basic.visual ; Hi grp!
Trying to receive a udp msg in vb6, but it shows only zeros. What have I
missed?
/Henning
--
Time is present only to prevent everything from happening at once.
Still it seems that everything happens at once.
...
-
Winsock what did I miss?
Hi grp!
Trying to receive a udp msg in vb6, but it shows only zeros. What have I
missed?
/Henning
--
Time is present only to prevent everything from happening at once.
Still it seems that everything happens at once.
Then there must be a bug in time.
To find the bug in time, isn't that what we all hope for.
-
SV: Winsock what did I miss?
;( as usual I "forgot" to attach the code ;(
Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
Dim byteData(256) As Byte
Dim i As Integer
Text4.Text = bytesTotal
Text3.Text = ""
Wsock.GetData byteData(), vbArray + vbByte, bytesTotal
For i = 0 To bytesTotal - 1
Text3.Text = Text3.Text + Hex$(byteData(i))
Next
End Sub
/Henning
"Henning" <computer_hero@coldmail.com> skrev i meddelandet
news:41b0c1f0$0$91256$57c3e1d3@news3.bahnhof.se...
> Hi grp!
> Trying to receive a udp msg in vb6, but it shows only zeros. What have I
> missed?
>
> /Henning
>
> --
> Time is present only to prevent everything from happening at once.
> Still it seems that everything happens at once.
> Then there must be a bug in time.
> To find the bug in time, isn't that what we all hope for.
>
>
-
Re: Winsock what did I miss?
In responce to the post:
On Fri, 3 Dec 2004 20:47:07 +0100, "Henning"
<computer_hero@coldmail.com> stated...and I replied:
>Hi grp!
>Trying to receive a udp msg in vb6, but it shows only zeros. What have I
>missed?
>
>/Henning
Did you send a msg? <g>
see next post
Shell
-
http://drshell.home.mindspring.com/
Into computers since 1972.
WARNING! Information and e-mail addresses contained herein, are for personal use only. By entering this site, you agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, electronic mail, or by telephone. Violators will be dealt with accordingly.
-
-
Re: SV: Winsock what did I miss?
In responce to the post:
On Fri, 3 Dec 2004 20:51:10 +0100, "Henning"
<computer_hero@coldmail.com> stated...and I replied:
>;( as usual I "forgot" to attach the code ;(
>Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
> Dim byteData(256) As Byte
^^^
this would be 0 to 256...are you sure you don't want 256 as the
amount? (e.g. 0 to 255?)
> Dim i As Integer
> Text4.Text = bytesTotal
> Text3.Text = ""
^^^
this would clear your receiving field each time the DataArrival event
fires
> Wsock.GetData byteData(), vbArray + vbByte, bytesTotal
> For i = 0 To bytesTotal - 1
> Text3.Text = Text3.Text + Hex$(byteData(i))
> Next
>End Sub
Do you know, in advance, the size of the data packet you're receiving?
If so, you can truncate the excess data...which is probably what is
clearing and zeroing your receiving field at the end of the
transmission.
Shell
-
http://drshell.home.mindspring.com/
Into computers since 1972.
WARNING! Information and e-mail addresses contained herein, are for personal use only. By entering this site, you agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, electronic mail, or by telephone. Violators will be dealt with accordingly.
-
-
SV: SV: Winsock what did I miss?
Jepp, I did send 
The Sniffer told the package is ok
When receiving to a string, it works.
So, the quiz stands. What have I missed when trying the byte array. Data in
pack is binary.
And yes, I know the package size. It comes from a standalone mpu project,
sending status changes of 8-bit ports. The 256 was just lazy
pkg size = 9
bytes + header.
/Henning
"Shell" <___computerNOSPAMconsultant@mindspring.com___> skrev i meddelandet
news:jhp1r0p80345odq53jaal69ss2id0a5r79@4ax.com...
> In responce to the post:
> On Fri, 3 Dec 2004 20:51:10 +0100, "Henning"
> <computer_hero@coldmail.com> stated...and I replied:
>
> >;( as usual I "forgot" to attach the code ;(
> >Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
> > Dim byteData(256) As Byte
> ^^^
> this would be 0 to 256...are you sure you don't want 256 as the
> amount? (e.g. 0 to 255?)
>
> > Dim i As Integer
> > Text4.Text = bytesTotal
> > Text3.Text = ""
> ^^^
> this would clear your receiving field each time the DataArrival event
> fires
>
> > Wsock.GetData byteData(), vbArray + vbByte, bytesTotal
> > For i = 0 To bytesTotal - 1
> > Text3.Text = Text3.Text + Hex$(byteData(i))
> > Next
> >End Sub
>
> Do you know, in advance, the size of the data packet you're receiving?
> If so, you can truncate the excess data...which is probably what is
> clearing and zeroing your receiving field at the end of the
> transmission.
>
> Shell
> -
> http://drshell.home.mindspring.com/
> Into computers since 1972.
> WARNING! Information and e-mail addresses contained herein, are for
personal use only. By entering this site, you agree that you will use this
data only for lawful purposes and that, under no circumstances will you use
this data to: allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via direct mail,
electronic mail, or by telephone. Violators will be dealt with accordingly.
> -
-
Re: SV: Winsock what did I miss?
"Henning" <computer_hero@coldmail.com> wrote in message
news:41b105e2$0$91271$57c3e1d3@news3.bahnhof.se...
| Jepp, I did send 
| The Sniffer told the package is ok
| When receiving to a string, it works.
| So, the quiz stands. What have I missed when trying the byte array.
Data in
| pack is binary.
"Henning" <computer_hero@coldmail.com> wrote in message
news:41b0c2e2$0$91256$57c3e1d3@news3.bahnhof.se...
| Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
| Dim byteData(256) As Byte
| Wsock.GetData byteData(), vbArray + vbByte, bytesTotal
I suspect that GetData is expecting a dynamic array, which it can resize
to fit the data. So just doing
Dim byteData() As Byte
might do it. If not, then it might be expecting vbArray + vbByte to mean
a variant containing a byte array, so
Dim byteData As Variant
might work.
-
Re: SV: Winsock what did I miss?
In responce to the post:
On Fri, 3 Dec 2004 18:13:28 -0800, "Steve Gerrard"
<mynamehere@comcast.net> stated...and I replied:
>
>"Henning" <computer_hero@coldmail.com> wrote in message
>news:41b105e2$0$91271$57c3e1d3@news3.bahnhof.se...
>| Jepp, I did send 
>| The Sniffer told the package is ok
>| When receiving to a string, it works.
>| So, the quiz stands. What have I missed when trying the byte array.
>Data in
>| pack is binary.
>
>"Henning" <computer_hero@coldmail.com> wrote in message
>news:41b0c2e2$0$91256$57c3e1d3@news3.bahnhof.se...
>
>| Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
>| Dim byteData(256) As Byte
>
>| Wsock.GetData byteData(), vbArray + vbByte, bytesTotal
>
>I suspect that GetData is expecting a dynamic array, which it can resize
>to fit the data. So just doing
> Dim byteData() As Byte
>might do it. If not, then it might be expecting vbArray + vbByte to mean
>a variant containing a byte array, so
> Dim byteData As Variant
>might work.
>
No sir, the GetData is somewhat like the Get/Input statements. They
require "sizing" to the amount of data to be received, and a ByteArray
is just fine for this purpose.
Shell
-
http://drshell.home.mindspring.com/
Into computers since 1972.
WARNING! Information and e-mail addresses contained herein, are for personal use only. By entering this site, you agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, electronic mail, or by telephone. Violators will be dealt with accordingly.
-
-
Re: SV: SV: Winsock what did I miss?
In responce to the post:
On Sat, 4 Dec 2004 01:37:03 +0100, "Henning"
<computer_hero@coldmail.com> stated...and I replied:
>Jepp, I did send 
>The Sniffer told the package is ok
>When receiving to a string, it works.
>So, the quiz stands. What have I missed when trying the byte array. Data in
>pack is binary.
>And yes, I know the package size. It comes from a standalone mpu project,
>sending status changes of 8-bit ports. The 256 was just lazy
pkg size = 9
>bytes + header.
>/Henning
>
The DataArrival event fires one to many times for each transmission.
Even for a small packet like 9 bytes you could still be getting a
second firing of the event, whereby the receiving field would be
cleared, as well as the byte array being overlayed each time you
GetData.
I would bet the DataArrival event fires more than once.
If you change the code to allow for multiple entry of the DataArrival
event, you will see results.
Shell
-
http://drshell.home.mindspring.com/
Into computers since 1972.
WARNING! Information and e-mail addresses contained herein, are for personal use only. By entering this site, you agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, electronic mail, or by telephone. Violators will be dealt with accordingly.
-
-
Re: SV: Winsock what did I miss?
"Shell" <___computerNOSPAMconsultant@mindspring.com___> wrote in message
news
ia4r0dirualqagflt1bm9ijvi9spdjvn8@4ax.com...
| >| When receiving to a string, it works.
| >| So, the quiz stands. What have I missed when trying the byte array.
| >| Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
| >| Dim byteData(256) As Byte
| >
| >I suspect that GetData is expecting a dynamic array, which it can
resize
| >to fit the data. So just doing
| > Dim byteData() As Byte
| >might do it.
| No sir, the GetData is somewhat like the Get/Input statements. They
| require "sizing" to the amount of data to be received, and a ByteArray
| is just fine for this purpose.
|
Good theory, but in fact incorrect. The examples in MSDN use unsized
strings, for instance, to receive text data, which gives a hint.
The following does work for receiving 4 bytes of data:
Private Sub Winsock3_DataArrival(ByVal bytesTotal As Long)
Dim bytes() As Byte
Dim n As Integer
Winsock3.GetData bytes, vbArray + vbByte
For n = LBound(bytes) To UBound(bytes)
Debug.Print n, bytes(n)
Next n
End Sub
If you replace the Dim statement with
Dim bytes(0 to 3) As Byte
the bytes will remain all zero.
-
SV: SV: Winsock what did I miss?
Anyone to bet a dollar on Steve?
He is right!
When I saw the reply, I simply hit myself hard!
Thx Steve for pointing that out, it works like a dream now!
Thx again
/Henning (in computers since 1979)
"Steve Gerrard" <mynamehere@comcast.net> skrev i meddelandet
news:9KadnQ1S6oshpi_cRVn-2Q@comcast.com...
>
> "Shell" <___computerNOSPAMconsultant@mindspring.com___> wrote in message
> news
ia4r0dirualqagflt1bm9ijvi9spdjvn8@4ax.com...
> | >| When receiving to a string, it works.
> | >| So, the quiz stands. What have I missed when trying the byte array.
>
> | >| Private Sub Wsock_DataArrival(ByVal bytesTotal As Long)
> | >| Dim byteData(256) As Byte
> | >
>
> | >I suspect that GetData is expecting a dynamic array, which it can
> resize
> | >to fit the data. So just doing
> | > Dim byteData() As Byte
> | >might do it.
>
> | No sir, the GetData is somewhat like the Get/Input statements. They
> | require "sizing" to the amount of data to be received, and a ByteArray
> | is just fine for this purpose.
> |
>
> Good theory, but in fact incorrect. The examples in MSDN use unsized
> strings, for instance, to receive text data, which gives a hint.
>
> The following does work for receiving 4 bytes of data:
>
> Private Sub Winsock3_DataArrival(ByVal bytesTotal As Long)
> Dim bytes() As Byte
> Dim n As Integer
>
> Winsock3.GetData bytes, vbArray + vbByte
> For n = LBound(bytes) To UBound(bytes)
> Debug.Print n, bytes(n)
> Next n
>
> End Sub
>
> If you replace the Dim statement with
> Dim bytes(0 to 3) As Byte
>
> the bytes will remain all zero.
>
>
>
Similar Threads
-
By Application Development in forum C
Replies: 0
Last Post: 11-05-2007, 06:38 AM
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 06-12-2007, 09:50 AM
-
By Application Development in forum Adobe Premiere
Replies: 1
Last Post: 09-19-2005, 04:06 PM
-
By Application Development in forum Graphics
Replies: 0
Last Post: 03-22-2005, 07:00 PM
-
By Application Development in forum Inetserver
Replies: 1
Last Post: 07-30-2003, 02:00 AM