Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2005

Tip: Looking for answers? Try searching our database.

Peculiar Error in Network Transmission

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pravin Prabhu - 14 Jul 2005 05:43 GMT
Hi,
   I am trying to transfer data from a Unix machine to Windows machine
using C Network functions.

   In unix i send image data to windows using send() function in a loop
running till the end of image data (length is known beforehand). sending 1022
bytes at a time

   when i send binary image data, i use recv command in windows to get data
1022 bytes at a time.it works fine.
   But when i try to send JPEG image data. Only the first 4 bytes of JPEG
header (FF D8 FF E0) are received. the rest of the 1018 bytes are not
received, in the next   send(), transmission starts from 1023 bytes after the
start of image data, from this point on data is transmitted and received
correctly.
   I have observed that if Image data has consecutive zeros - 00 i.e 0x30
0x30. Data is either not read by recv() or transmitted by send() [i actually
dont know which command is at fault since both return 1022 bytes data
read/written].

Any help will be greatly appreciated.

thanks and regards
Pravin Prabhu - 14 Jul 2005 08:02 GMT
Actually i figured out the problem, I am using a String Array to write data
from Image file and am using this String Array to transmit data using Send().
The 00 is a NULL character in C and when encountered in the array C thinks
the Array has ended.
But the JPEG image data i want to transfer contains a lot of NULL characters
(viewed using Hex editor), and i want to transfer the data through the
network. How can I use a BYTE Array in C? Any suggestions?

> Hi,
>     I am trying to transfer data from a Unix machine to Windows machine
[quoted text clipped - 19 lines]
>
> thanks and regards
Nishant Sivakumar - 14 Jul 2005 11:58 GMT
Are you using Winsock? Or some higher level wrapper library?

If you are using Winsock, the 3rd parameter to send() is the length in bytes
of the byte array (2nd parameter).

Signature

Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com

> Actually i figured out the problem, I am using a String Array to write
> data
[quoted text clipped - 36 lines]
>>
>> thanks and regards
Pravin Prabhu - 14 Jul 2005 12:40 GMT
Hi Nishanth,
              I am using Winsock on the windows side for recv().
              Actually the send() command is in the unix side. I do give
the Length of the array (1022 bytes). but the problem is that there is a null
character at the 5th position of the array. There are a lot of null
characters in the image data stored in the array. Since NULL is the end of
string in C, i am facing problems sending the whole image data.

> Are you using Winsock? Or some higher level wrapper library?
>
[quoted text clipped - 41 lines]
> >>
> >> thanks and regards
Nishant Sivakumar - 14 Jul 2005 12:53 GMT
You are trying to use null-terminated strings to store binary data. That's
your basic problem.

Instead use a char array [but do not use any string manipulation functions
on it] or use a void* instead. And then use the Buffer-Manipulation Routines
like memcpy, memcmp etc.

Signature

Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com

> Hi Nishanth,
>               I am using Winsock on the windows side for recv().
[quoted text clipped - 58 lines]
>> >>
>> >> thanks and regards
Pravin Prabhu - 14 Jul 2005 13:19 GMT
Hi Nishant,
              Actually I am storing (binary) Image data which i obtain from
an imaging device in a Char Array. The Image data already has lots of null
characters as part of image data, so when i copy into a char array it
automatically becomes a null terminated string. and when i try to transmit
the Char array i face problems.

> You are trying to use null-terminated strings to store binary data. That's
> your basic problem.
[quoted text clipped - 65 lines]
> >> >>
> >> >> thanks and regards

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.