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. 12 8734
;( as usual I "forgot" to attach the code ;(
Private Sub Wsock_DataArriv al(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" <co***********@ coldmail.com> skrev i meddelandet
news:41******** *************** @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.
In responce to the post:
On Fri, 3 Dec 2004 20:47:07 +0100, "Henning"
<co***********@ 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.
-
In responce to the post:
On Fri, 3 Dec 2004 20:51:10 +0100, "Henning"
<co***********@ coldmail.com> stated...and I replied: ;( as usual I "forgot" to attach the code ;( Private Sub Wsock_DataArriv al(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.
-
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" <__************ *************@m indspring.com__ _> skrev i meddelandet
news:jh******** *************** *********@4ax.c om... In responce to the post: On Fri, 3 Dec 2004 20:51:10 +0100, "Henning" <co***********@ coldmail.com> stated...and I replied:
;( as usual I "forgot" to attach the code ;( Private Sub Wsock_DataArriv al(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. -
"Henning" <co***********@ coldmail.com> wrote in message
news:41******** *************** @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" <co***********@ coldmail.com> wrote in message
news:41******** *************** @news3.bahnhof. se...
| Private Sub Wsock_DataArriv al(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.
In responce to the post:
On Fri, 3 Dec 2004 18:13:28 -0800, "Steve Gerrard"
<my********@com cast.net> stated...and I replied: "Henning" <co***********@ coldmail.com> wrote in message news:41******* *************** *@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" <co***********@ coldmail.com> wrote in message news:41******* *************** *@news3.bahnhof .se...
| Private Sub Wsock_DataArriv al(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.
-
In responce to the post:
On Sat, 4 Dec 2004 01:37:03 +0100, "Henning"
<co***********@ 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.
-
"Shell" <__************ *************@m indspring.com__ _> wrote in message
news:oi******** *************** *********@4ax.c om...
| >| When receiving to a string, it works.
| >| So, the quiz stands. What have I missed when trying the byte array.
| >| Private Sub Wsock_DataArriv al(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_DataAr rival(ByVal bytesTotal As Long)
Dim bytes() As Byte
Dim n As Integer
Winsock3.GetDat a 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.
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" <my********@com cast.net> skrev i meddelandet
news:9K******** ************@co mcast.com... "Shell" <__************ *************@m indspring.com__ _> wrote in message news:oi******** *************** *********@4ax.c om... | >| When receiving to a string, it works. | >| So, the quiz stands. What have I missed when trying the byte array.
| >| Private Sub Wsock_DataArriv al(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_DataAr rival(ByVal bytesTotal As Long) Dim bytes() As Byte Dim n As Integer
Winsock3.GetDat a 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Niels Borg |
last post by:
Hi,
I'm writing app where I use WinSock, but I have experienced a problem.
WinSock only sends the data after finishing the calling sub/function. Can I
force WinSock immediately as I need to send several packets but they have to
be sent separate?
Many thanks
Niels Borg
|
by: Bill |
last post by:
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...).
Why doesn't this work, and is there a work around I can make on the C# side to hear the connect request?
-Bill
(don't reply by e-mail, the address is a fake)
______________________________
Steps to reproduce:
Start the C# Listener
|
by: Yu Chai |
last post by:
Hi guys,
I created a ASP page that
1. users can run when WinSock proxy are using (ie's one is unchecked)
2. users can't run when WinSock proxy are using (ie's one is checked)
3. users can't run when WinSock proxy are not using (ie's one is checked)
4. users can't run when WinSock proxy are not using (ie's one is unchecked)
So, what is the difference between winsock proxy client and the proxy
setting in browser (IE)?
|
by: Nadav |
last post by:
Hi
I am writing some kind of a storage system that have to deal with large amounts of data passing over the net, Now, I Wonder... traditional programming would use win32 Winsock DLL as the means of data transportation... now, indigo is the new communication layer of the CLR,
- Does indigo uses Winsock internally?
- Is it possible to use indigo for such a task?
- I assume using indigo has it's performance penalty ( doesn't it ?
- Does...
|
by: John |
last post by:
Hello,
I currently have Visual Basic .NET 2003 Standard Edition. I would like to
develop a standard exe which should use the Winsock Control for VB.NET. I
found some tutorials about it, started to work, and then found out I
couldn't find the winsock control at all. Is it there by default and am I
just missing something? (Running WinXP Home, VB.NET Standard, no other VS
programs installed) Or could I download it from MS if it isn't? I...
| |
by: kc |
last post by:
Hi
Just upgrading a app from VB6 to VB.Net. All is going well apart from the
Winsock control.
The first thing we notice is that there does not appear to be a .Net version
(please correct me if wrong).
Also when we use the VB6 winsock control in a dotnet version we appear to
lose the ability of creating an array on winsock's.
for example we cannot assign as thus
|
by: Nicolas Ghesquiere |
last post by:
Hello
I have a problem with my current program.
The meaning of the program is to allow users to login to a server to allow
them to access the internet.
My program communicates with a MS isa server to make a rule for that IP for
the time-credits left for that user.
My problem is that so far, the program can handle everything except more
then one client, and i have done my best, but i can't find a decent solution
|
by: imaloner |
last post by:
I am posting two threads because I have two different problems, but both have the same background information.
Common Background Information:
I am trying to rebuild code for a working, commercially sold application with only partial build instructions. The previous maintainer of the code (a
mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
|
by: AaronL |
last post by:
Hello,
I am currently working on a project that has me in sort of a bind. What I want to do is retrieve web pages from the internet, and strip them down to just text. I'll get using Regular Expressions to strip out the HTML code itself, the problem is actually getting the web pages from the internet.
I tried using the Microsoft Internet Transfer Control but my client was experiencing problems with some web pages not downloading, this...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |