-
July 24th, 2014, 03:08 AM
#1
Which ASCII character to send
I want to send only one character to the other side to signal that there was an error.
I'm looking for a character that never appears in a file.
I looked at the ASCII chart and I thought maybe:
- 127 177 7F 01111111 Delete
or
- 129 201 81 10000001
http://www.ascii-code.com/
-
July 24th, 2014, 04:33 AM
#2
Re: Which ASCII character to send
ASCII character 0x81 is the small u umlaut. See http://www.theasciicode.com.ar/
DEL character (127) can be used by some OS for special purposes. See http://en.wikipedia.org/wiki/ASCII and http://en.wikipedia.org/wiki/Delete_character
Victor Nijegorodov
-
July 24th, 2014, 08:22 AM
#3
Re: Which ASCII character to send
Thank you Victor.
Looks like the DEL character should be OK on Windows.
-
July 24th, 2014, 08:49 AM
#4
Re: Which ASCII character to send
I'm looking for a character that never appears in a file.
Depends somewhat upon whether a file is type 'text' or 'binary'. In a binary ASCII file any of the characters from 0 to 255 may appear. In a 'text' file 1 - 6, 14 - 26, 28 - 31 and 255 are unlikely to occur.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 24th, 2014, 12:09 PM
#5
Re: Which ASCII character to send
It's for binary too so maybe just one character is not the best solution.
Thanks Kaud, that's what I wanted to know.
Last edited by MasterDucky; July 24th, 2014 at 12:11 PM.
-
July 24th, 2014, 01:00 PM
#6
Re: Which ASCII character to send
You could base64 encode the file contents, then use a NAK (21) (or whatever) in your protocol.
gg
-
July 24th, 2014, 02:24 PM
#7
Re: Which ASCII character to send
Originally Posted by MasterDucky
It's for binary too so maybe just one character is not the best solution.
Thanks 2Kaud, that's what I wanted to know.
What are you trying to achieve? If you are using binary files then any sequence of one or more characters could possibly occur in any file.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 24th, 2014, 02:43 PM
#8
Re: Which ASCII character to send
Originally Posted by 2kaud
What are you trying to achieve? If you are using binary files then any sequence of one or more characters could possibly occur in any file.
Thats true.
I would like to signal to the other side that an error occurred and dont wait for the file.
-
July 24th, 2014, 02:45 PM
#9
Re: Which ASCII character to send
Originally Posted by Codeplug
You could base64 encode the file contents, then use a NAK (21) (or whatever) in your protocol.
Base64 doesnt use all the ASCII characters?
-
July 24th, 2014, 02:55 PM
#10
Re: Which ASCII character to send
Originally Posted by MasterDucky
I want to send only one character to the other side to signal that there was an error.
I'm looking for a character that never appears in a file.
How do you "send" your file?
Victor Nijegorodov
-
July 25th, 2014, 02:13 AM
#11
Re: Which ASCII character to send
Originally Posted by VictorN
How do you "send" your file?
Windows TCP/IP Send() function.
-
July 25th, 2014, 02:31 AM
#12
Re: Which ASCII character to send
If all you want to do is to signal an error from the send side, what about just closing the connection? This will be picked up by recv() as an error for which you can test. If you want to resend then the sender can re-open the connection etc.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 25th, 2014, 03:04 AM
#13
Re: Which ASCII character to send
Originally Posted by Codeplug
You could base64 encode the file contents, then use a NAK (21) (or whatever) in your protocol.
gg
This looks like the best solution.
-
July 25th, 2014, 03:18 AM
#14
Re: Which ASCII character to send
Also look at the shutdown function in MSDN.
Besides, this thread is a very good example of how one should NOT ask the question.
The more reliable question about your problem should have looked like:
I send a file through a TCP socket.
If some error occured on the sender side, what should I do or what should I send to the receiver to inform that send operation is broken?
Then you would have got the valuable answer in some minutes, not in 11 hours!
Victor Nijegorodov
-
July 25th, 2014, 10:53 AM
#15
Re: Which ASCII character to send
Yes, but I want to know if it was an error with the connection or with some other operation, like couldn't open a file I asked for or anything else.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|