473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB6 Winsock receiving NULL error?

I am creating an interface program to connect to a Panasonic PBX.
I am using VB6 with the Winsock control.

I can connect to the PBX's IP address/port OK and it accepts my connection.

I can send the initial connection string to the PBX as follows:

Expand|Select|Wrap|Line Numbers
  1. Mtosend = Chr$(&H0) & Chr$(&H25) & Chr$(&H60) & Chr$(&H23) & Chr$(&H80) & Chr$(&H2) & Chr$(&H7) & Chr$(&H80) & Chr$(&HA1) & Chr$(&H7) & Chr$(&H6) & Chr$(&H5) & Chr$(&H2B) & Chr$(&HC) & Chr$(&H0) & Chr$(&H81) & Chr$(&H5A) & Chr$(&HBE) & Chr$(&H14) & Chr$(&H28) & Chr$(&H12) & Chr$(&H6) & Chr$(&H7) & Chr$(&H2B) & Chr$(&HC) & Chr$(&H0) & Chr$(&H82) & Chr$(&H1D) & Chr$(&H81) & Chr$(&H48) & Chr$(&HA0) & Chr$(&H7) & Chr$(&HA0) & Chr$(&H5) & Chr$(&H3) & Chr$(&H3) & Chr$(&H0) & Chr$(&H8) & Chr$(&H0)
  2. Winsock1.SendData Mtosend
When I monitor the TCP packets using WireShark, I can see that the phone switch acepted my packet properly and sent the proper 51-byte reply, but when I try to read the reply data in Winsock, it informs me that 51 bytes have been received OK, but the received data (read as a string) shows as a "null" string.
If I use the following code to retrieve the 51 byte data into a byte array, I get 51 zero's - in Wireshark I can see that the data packet only started with 0 (null) but the rest looked like valid data.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  2. Dim DL As String
  3. Dim DTS As String
  4. Dim byteData(256) As Byte
  5. Dim i As Integer
  6. DL = CStr(bytesTotal)
  7. DTS = ""
  8. Winsock1.GetData byteData(), vbArray + vbByte, Val(Trim(DL))
  9. For i = 0 To bytesTotal - 1
  10.     DTS = DTS & " " & Right$(("00" & Hex$(byteData(i))), 2)
  11. Next
  12. SaveLog "TCP Rx: " & DTS & "  (bytes=" & DL & ")"
  13. Exit Sub

Please help - how can I get the proper data?

What am I doing wrong?
Oct 15 '08 #1
0 1333

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Henning | last post by:
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...
4
by: Ophir | last post by:
Hello all ! I wrote a simple ActiveX DLL to wrap winsock functionality so I can use it in an ASP page. I call it MyWinSock In the Class module I use this declaration: Dim ctlSocket as...
3
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...
4
by: Ramiro Barbosa, Jr. | last post by:
All, In regards to the call below, I was wondering why is it that the 'szMessage' receiving buffer results in an empty one, but by printing 'ret' it indicates the number of bytes I am indeed...
0
by: hamil | last post by:
Since there is no Winsock for VB.net, I am trying to use the Winsock control from VB 6 in my VB.net program. I have "imported" the control to the VB.net toolbox and am able to connect to a remote...
2
by: Mark | last post by:
Hi, I have a VB6 project that uses a winsock control to receive text messages over a UDP connection. It used to work fine. However, when I changed the code to make it more efficient (ie, less...
1
by: raj.rr7 | last post by:
Hi, I am creating a Http client application using winsock, evc++ 4.0 and K- Jam (WIndows Mobile 5) that will get data from Http server. I am using the following code. WSADATA wsaData;...
4
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,...
3
AaronL
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.