473,748 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Peculiar Error in Network Transmission

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
Nov 17 '05 #1
5 1217
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?

"Pravin Prabhu" wrote:
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

Nov 17 '05 #2
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).

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
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?

"Pravin Prabhu" wrote:
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

Nov 17 '05 #3
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.

"Nishant Sivakumar" wrote:
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).

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
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?

"Pravin Prabhu" wrote:
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


Nov 17 '05 #4
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.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:7F******** *************** ***********@mic rosoft.com...
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.

"Nishant Sivakumar" wrote:
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).

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
> 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?
>
> "Pravin Prabhu" wrote:
>
>> 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



Nov 17 '05 #5
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.

"Nishant Sivakumar" wrote:
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.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:7F******** *************** ***********@mic rosoft.com...
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.

"Nishant Sivakumar" wrote:
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).

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Pravin Prabhu" <Pr**********@d iscussions.micr osoft.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
> 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?
>
> "Pravin Prabhu" wrote:
>
>> 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


Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1975
by: Matthias Stock | last post by:
Hello, i want to simulate a transmission network. Therefore I must create some blocks, e.g. random integer generator, AWGN, etc. Does anyone know if there exist some libraries (for example like Numerical Recipes) for communication technology? Thanks for your help, Matthias.
1
2738
by: Kim Hamilton | last post by:
Hello, I'm using a C++ program to write out a file using sopen(). The file is pointed to a network drive. Some times the network goes down, and the file errors out. Is there any way to spool the file locally, and when the network returns, rewrite the file out to the network ? I can probably write some code to do all of that, but didn't know if there were any API calls, say setting to output file as a print spool type.
1
7336
by: Bekkali Hicham | last post by:
hi, i have already used xalan several times with success, but i have a error message that i don't understand, thanks for your help (Emplacement inconnu de l'erreur) Erreur XSLT (javax.xml.transform.TransformerConfigurationException): javax.xml.transform.TransformerException: java.io.UTFData FormatException: Invalid byte 2 of 3-byte UTF-8 sequence. thanks
1
1637
by: James Fortune | last post by:
In order to get the records I want on a report I sometimes create a SQL string for the RecordSource and sometimes supply the criteria using the Filter Property. If I use the Filter Property rather than a RecordSource returning just the values I want is there extra traffic across the network to bring the unfiltered data to the front end? Thanks, James A. Fortune
2
5138
by: Leonardo D'Ippolito | last post by:
Hi! I have two .NET win apps that need to communicate on a TCP/IP network. 'App A' must ask 'app B' if it's allowed to do some task, and 'app B' must authorize or prohibit it. How can I do this kind of communication in a secure way (protected from sniffing)? It would be a very simple protocol. Question, and two possible answers 'yes' or 'no'.
1
1699
by: Sammy | last post by:
I am using the following code on a company that hosts our web site. I have noticed lately that their mail server/smtp is unavailable several times a minute for a second or two. This is causing my script to fail when it calls the client.Send(msg); Will adding "client.Timeout = 1000000;" help my problem if the server can't be reached or does the timeout assume the server can be reached but waits for it to become less busy? // create...
4
2183
by: Bgreer5050 | last post by:
I keep getting the following error on an asp form I have on my site. I know the smtp settings are correct, because if I take out the user fields (i.e. name, weight and assign a text string in code the email is processed. Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click Const ToAddress As String = abc@abc.com Dim mm As New Net.Mail.MailMessage(abc@abc.com, ToAddress) mm.Subject =...
4
1645
by: parez | last post by:
Hi, When does the socket (server) know when to stop reading. e.g. if i have a buffer = 25K and do networkStream.write twice.. what will the server read? 25k or 50K?
1
1869
by: mariuchp | last post by:
Can somebody help me. Is it a good method to transfer large data accros network? The query returns about 1 milion rows, and I must transfer them to client application and generate .xml files. Unfortunatelly it takes more then hour (sometimes I get timeout exception) :(. Query takes about 1min, so transfer is a big problem :|. I'm using C# and WebServices
0
8980
marktang
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...
0
9523
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, 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...
0
9356
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 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...
1
9307
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
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, 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...
1
6791
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4862
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2204
bsmnconsultancy
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...

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.