[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-bugs
Subject: [haiku-bugs] Re: [Haiku] #4923: netcat cuts off ending of stream
From: "Adek336" <trac () haiku-os ! org>
Date: 2009-11-30 4:22:45
Message-ID: 051.0bd265a4959a70394f1da03ca497b091 () haiku-os ! org
[Download RAW message or body]
#4923: netcat cuts off ending of stream
---------------------------------------------+------------------------------
Reporter: Adek336 | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: R1
Component: Applications/Command Line Tools | Version: R1/alpha1
Keywords: | Blockedby:
Platform: All | Blocking:
---------------------------------------------+------------------------------
Comment(by Adek336):
Program writing hexadecimals to `hostn:2345`.
{{{
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main()
{
int sock;
struct sockaddr_in server;
struct hostent *hp;
sock = socket (PF_INET, SOCK_STREAM, 0);
if (sock < 0)
exit(1);
const char *hostn = "192.168.1.100";
hp = gethostbyname (hostn);
if (hp == NULL)
exit(1);
server.sin_family = AF_INET;
memcpy ((char *) &server.sin_addr, (char *) hp->h_addr,
hp->h_length);
server.sin_port = htons (2345);
if (connect (sock, (struct sockaddr *) &server, sizeof server) <
0)
exit(1);
int u = 0;
do
{
char line[1000];
snprintf(line, 1000, "%07x\n", ++ u);
size_t sent = 0;
size_t to_send = strlen(line);
while (sent < to_send)
{
int w = write(sock, line + sent, to_send - sent);
if (w == 0)
break;
if (w == -1)
break;
int j;
//for (j = sent; j < sent+w; ++j)
//printf("%c", line[j]);
sent += w;
}
}
while (u < 0x01000000);
close (sock);
return 0;
}
}}}
Change hostn; compile the program under Haiku; run `nc -lp2345` on a linux
box; run the program under Haiku.
We observe that netcat receives lines of seven digit, zero padded
hexadecimals. After a while, netcat starts to print only the three least
significant digits of the numbers it should receive. Does not happen if
the client program is run on linux. Reproducible with Haiku, under
VirtualBox, r34335 hybr2.
Additionally, if I create the file `a.c` with the contents of `int main()
{ }` and run the command `while true; do gcc a.c; done` in the background,
the stream seems to get corrupted sooner.
--
Ticket URL: <http://dev.haiku-os.org/ticket/4923#comment:2>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic