View mode: basic / threaded / horizontal-split · Log in · Help
July 21, 2005
Extra socket output problem
Hi all.
I am writing a telnet-like application, and am experiencing some strange 
behavior with my sockets.  When the user hits enter,  the text is sent, but 
before that 4 extra bytes (usually ctrl-b and 3 nulls) are sent.  What does 
this mean, and how can I avoid it?
July 21, 2005
Re: Extra socket output problem
"Ameer Armaly" <ameer_armaly@hotmail.com> wrote in message 
news:dbo7ej$272m$1@digitaldaemon.com...
> Hi all.
> I am writing a telnet-like application, and am experiencing some strange 
> behavior with my sockets.  When the user hits enter,  the text is sent, 
> but before that 4 extra bytes (usually ctrl-b and 3 nulls) are sent.  What 
> does this mean, and how can I avoid it?

Is it the length of the string about to be sent? I kindof doubt it since it 
would be odd if all your test strings had the same length. Posting some code 
would help. For example if you are using std.stream the method write(char[]) 
will first send the length and then the string contents. The result must be 
read using read (and watch out about endianness if you go this route).
July 27, 2005
Re: Extra socket output problem
Ameer Armaly wrote:
> Hi all.
> I am writing a telnet-like application, and am experiencing some strange 
> behavior with my sockets.  When the user hits enter,  the text is sent, but 
> before that 4 extra bytes (usually ctrl-b and 3 nulls) are sent.  What does 
> this mean, and how can I avoid it? 
> 
> 

I encountered similar behaviour when I wrote a simple HTTP client. I 
cannot find the sources for it, but I ensured the client only sent an 
array of bytes (byte[]) - that way no other information is transmitted 
except what you explicitly specify.

-Tim
July 27, 2005
Re: Extra socket output problem
"Tim Laurent" <nanobyte@gmx.com> wrote in message 
news:dc8gic$b4r$1@digitaldaemon.com...
> Ameer Armaly wrote:
>> Hi all.
>> I am writing a telnet-like application, and am experiencing some strange 
>> behavior with my sockets.  When the user hits enter,  the text is sent, 
>> but before that 4 extra bytes (usually ctrl-b and 3 nulls) are sent. 
>> What does this mean, and how can I avoid it?
>
> I encountered similar behaviour when I wrote a simple HTTP client. I 
> cannot find the sources for it, but I ensured the client only sent an 
> array of bytes (byte[]) - that way no other information is transmitted 
> except what you explicitly specify.
>
> -Tim

note Ameer emailed me offline and he was reading using readLine and sending 
using write so the first 4 bytes he saw were indeed the length of the string 
in platform-dependent byte order.
Top | Discussion index | About this forum | D home