Jan Pechanec wrote:
> On Sat, 3 Jan 2009, Roland Mainz wrote:
>
>
>>> nc(1) is good enough for that if you use non-privileged ports. I
>>> think that would make a better test than using standard services supposedly
>>> already running since what if they didn't, from whatever reason.
>>>
>> Well, the drawback is that it would require to make SUNWosdem depend on
>> the SUNWnetcat package...
>>
>
> that's true - SUNWsndmu and SUNWsndmr are in the "Minimal Core
> System Support" metacluster while netcat is in the "Entire Distribution" one
> so netcat might not be always available...
>
>
I'm surprised you just don't write a little tcp server/client pair. It
really isn't that hard to do. You could probably write both halves in
ksh93, and deliver them *both* in your SUNWosdem package. (Hint: the
server for such a program could just use a randomly selected port, and
be single threaded without support for concurrent connections, and run
fully synchronously. "echo" would be almost trivial to write using this:
struct sockaddr_in sin, peer;
char buf[512];
sin.sin_family = AF_INET;
sin.sin_port = /* some random port */;
sin.sin_addr = inet_addr("127.0.0.1");
sock= socket(PF_INET, SOCK_STREAM, 0);
listen(sock, 5);
sockaddr.
bind(sock, &sin, sizeof (sin));
accept(sock, &peer, sizeof (peer));
while ((n = read(sock, buf, sizeof (buf)) > 0) {
int off = 0, resid = n, c;
while (resid) {
if ((c = write(sock, buf + off, resid)) < 1) {
perror("write");
abort();
}
resid -= c;
off += c;
}
}
That's pretty much the entire logic for such a simple echo server.
-- Garrett
_______________________________________________
networking-discuss mailing list
[email protected]