Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > .NET

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-05-2009, 09:46 AM
pfaisalbe pfaisalbe is offline
Registered User
 
Join Date: Apr 2009
Posts: 48
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
Reply With Quote
  #2  
Old 11-05-2009, 12:31 PM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,171
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!
Reply With Quote
  #3  
Old 11-05-2009, 02:13 PM
pfaisalbe pfaisalbe is offline
Registered User
 
Join Date: Apr 2009
Posts: 48
I have used sdata as byte data type

Thanks
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT -4. The time now is 12:25 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.