|
#1
|
|||
|
|||
|
RECEVING BINARY DATA using WINSOCK
Hi
I am using winsock to receive binary data from an electronic device. PC and electronic device are in adhoc configuration. My C code works very well but VB.net code doesnot work well which gives data which are not in binary. Here is my C code first int nlen = 32768; char SendBuf[800],RecvBuf[65535]; i = 0; FILE * pFile; pFile = fopen("mybin.bin","ab"); while(i != (nlen + 3)) { recv(m_socket, &byte, 1, 0); RecvBuf[i] = byte; i++; } fwrite(RecvBuf, 1, nlen + 3, pFile); Hers is vb.net code i = 0 j = 0 'For i = 0 To 32768 + 3 SOCKET.GetData(sData, VariantType.Byte, eventArgs.bytesTotal) SOCKET.Refresh() FileOpen(iFileNumber, Environment.CurrentDirectory & " mybin.bin", OpenMode.Append) PrintLine(iFileNumber, sData) FileClose(iFileNumber) 'Next What is the error in VB.net code Please suggest Regards |
|
#2
|
|||
|
|||
|
What data type is the variable sData? If it's a string, that would explain why the data does not appear to be binary. I would use an array of bytes.
__________________
Phil Weber http://www.philweber.com Please post questions to the forums, where others may benefit. I do not offer free assistance by e-mail. Thank you! |
|
#3
|
|||
|
|||
|
I have used sdata as byte data type
Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Saving data in a binary file | teja8100 | VB Classic | 6 | 07-08-2005 07:03 PM |
| Winsock: Transmitting raw data | jdt141 | C++ | 8 | 05-04-2005 06:18 PM |
| Re: sending binary data with XML - update | Joar Vatnaland | XML | 0 | 05-18-2001 05:37 AM |
| Access to binary data | James | Database | 1 | 03-20-2001 07:52 AM |
| Complex Data Consumer Data Aware Classes | Desmond Cassidy | authorevents.kurata | 3 | 04-19-2000 04:54 AM |